How to use the server/db.one function in server

To help you get started, we’ve selected a few server examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 1ven / do / test / server / models / Activity.spec.js View on Github external
it('should append to activity item corresponding entry data and remove entry_id, entry_table', () => {
      return db.one(
        `SELECT id, created_at, action, entry_id, entry_table
        FROM activity WHERE id = 1`
      )
        .then(activityItem => {
          return Activity._transformActivityItem(activityItem);
        })
        .then(transformed => {
          assert.property(transformed, 'created_at');
          assert.deepEqual(_.omit(transformed, ['created_at']), {
            id: 1,
            action: 'Updated',
            type: 'card',
            entry: {
              title: 'test card',
              link: `/boards/${boardId}/cards/${cardId}`,
            },
github 1ven / do / test / server / models / Base.spec.js View on Github external
                .then(() => db.one('SELECT id, title FROM boards WHERE id = 2'))
                .then(updatedBoard => assert.deepEqual(updatedBoard, {
github 1ven / do / test / server / models / List.spec.js View on Github external
.then(list => {
          return db.one(
            'SELECT board_id FROM boards_lists WHERE list_id = $1',
            [list.id]
          );
        })
        .then(result => {
github 1ven / do / test / server / api / base-api.spec.js View on Github external
                .then(() => db.one('SELECT * from test_1 WHERE id = 2'))
                .then(entry => {
github 1ven / do / test / server / models / Comment.spec.js View on Github external
.then(comment => {
          return db.one(
            `SELECT card_id FROM cards_comments WHERE comment_id = $1`,
            [comment.id]
          );
        })
        .then(result => {
github 1ven / do / test / server / routes / api / trash.spec.js View on Github external
return authenticate().then(request => {
    return db.one(`SELECT id FROM users`)
      .then(({ id }) => {
        return db.none(
          `INSERT INTO boards(id, title, deleted)
          VALUES ($2, 'test board 1', $4), ($3, 'test board 2', null);
          INSERT INTO users_boards VALUES ($1, $2), ($1, $3)`,
          [id, boardId, board2Id, now]
        );
      })
      .then(() => request);
  });
}
github 1ven / do / test / server / routes / lists-routes.spec.js View on Github external
.end((err, res) => {
                    if (err) { done(err); }

                    assert.equal(res.body.success, true);

                    db.one('SELECT * FROM boards WHERE id = $1', [boardId])
                        .then(board => {
                            assert.deepEqual(board.lists, [1]);
                        })
                        .then(() => {
                            const promise = db.one('SELECT * FROM lists WHERE id = $1', [listId]);
                            return expect(promise).to.be.rejectedWith(/No data returned from the query/);

                        })
                        .then(done, done);
                });
            });
github 1ven / do / test / server / models / Base.spec.js View on Github external
                .then(() => db.one('SELECT board_id, list_id FROM boards_lists WHERE board_id = 2'))
                .then(entry => assert.deepEqual(entry, { board_id: 2, list_id: 1 }));
github 1ven / do / test / server / routes / lists-routes.spec.js View on Github external
.end((err, res) => {
                    if (err) { done(err); }

                    assert.equal(res.body.success, true);

                    const listId = res.body.data.listId;

                    db.one('SELECT * FROM lists WHERE id = $1', [listId])
                        .then(list => assert.equal(list.title, listTitle))
                        .then(() => db.one('SELECT * FROM boards WHERE id = $1', [boardId]))
                        .then(board => {
                            assert.include(board.lists, listId);
                        })
                        .then(done, done);
                });
            });
github 1ven / do / test / server / routes / cards-routes.spec.js View on Github external
.then(() => {
                            const promise = db.one('SELECT * FROM cards WHERE id = $1', [cardId]);
                            return expect(promise).to.be.rejectedWith(/No data returned from the query/);
                        })
                        .then(done, done);