How to use the server/db.query 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 / db / index.spec.js View on Github external
it('should remove entry from `lists_cards` after corresponding card was removed', () => {
      return db.query(
        `INSERT INTO lists(id, title) VALUES ('3', 'test list');
        INSERT INTO cards(id, text) VALUES ('8', 'test card');
        INSERT INTO lists_cards VALUES ('3', '8');
        DELETE FROM cards WHERE id = '8'`
      )
        .then(() => db.query('SELECT * FROM lists_cards'))
        .then(result => assert.lengthOf(result, 0));
    });
  });
github 1ven / do / test / server / db / index.spec.js View on Github external
function selectColumnsInfo(table) {
  return db.query(
    `SELECT column_name, data_type
    FROM information_schema.columns
    WHERE table_name = $1`
    , table
  );
}
github 1ven / do / test / server / models / Base.spec.js View on Github external
                .then(() => db.query('SELECT id, title FROM boards'))
                .then(boards => assert.deepEqual(boards, [
github 1ven / do / test / server / routes.spec.js View on Github external
.end((err, res) => {
                            if (err) { return done(err); }

                            assert.equal(res.statusCode, 201);
                            assert.deepEqual(res.body, {
                                result: {
                                    id: 1,
                                    title: 'test board 1',
                                }
                            });

                            db.query('SELECT board_id FROM users_boards WHERE user_id = 1')
                                .then(result => result.map(item => item.board_id))
                                .then(ids => assert.include(ids, 1))
                                .then(done, done);
                        });
                });
github 1ven / do / test / server / db / index.spec.js View on Github external
        .then(() => db.query('SELECT * FROM boards_lists'))
        .then(result => assert.lengthOf(result, 0));
github 1ven / do / test / server / models / Board.spec.js View on Github external
    const findBoards = () => db.query(
      `SELECT id, title FROM boards AS b
      INNER JOIN users_boards AS ub ON (user_id = $1 AND ub.board_id = b.id)
      GROUP BY b.id, ub.board_index
      ORDER BY ub.board_index`,
      [userId]
    );
github 1ven / do / test / server / api / base-api.spec.js View on Github external
                .then(() => db.query('SELECT * FROM test_1'))
                .then(result => {
github 1ven / do / test / server / api / cards-api.spec.js View on Github external
beforeEach(() => {
        return db.query('DROP TABLE IF EXISTS cards')
        .then(() => db.query(sql('cards.sql')));
    });