Simple image host.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

collection_create.node.js 407B

1234567891011121314151617181920212223
  1. module.exports = function(ctx) {
  2. ctx.getPostData(function(err, data) {
  3. if (err) return ctx.fail(err);
  4. ctx.db.query(
  5. "INSERT INTO collections (name) "+
  6. "VALUES ($1) "+
  7. "RETURNING id",
  8. [data.name],
  9. queryCallback
  10. );
  11. });
  12. function queryCallback(err, res) {
  13. if (err) return ctx.fail(err);
  14. ctx.session.collectionId = res.rows[0].id;
  15. ctx.succeed({
  16. id: res.rows[0].id
  17. });
  18. }
  19. }