How to use the knex.Promise function in knex

To help you get started, we’ve selected a few knex 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 Vincit / objection.js / tests / integration / jsonQueries.js View on Github external
'use strict';

var _ = require('lodash');
var expect = require('expect.js');
var Promise = require('knex').Promise;
var Model = require('../../').Model;

function expectIdsEqual(resultArray, expectedIds) {
  expectArraysEqual(_(resultArray).map('id').sort().value(), expectedIds);
}

function expectArraysEqual(arr1, arr2) {
  expect({arr : arr1}).to.eql({arr: arr2});
}

module.exports = function (session) {

  function ModelJson() {
    Model.apply(this, arguments);
  }
  Model.extend(ModelJson);
github Vincit / objection.js / tests / integration / find.js View on Github external
'use strict';

var _ = require('lodash');
var utils = require('../../lib/utils/dbUtils');
var expect = require('expect.js');
var Promise = require('knex').Promise;

module.exports = function (session) {
  var Model1 = session.models.Model1;
  var Model2 = session.models.Model2;

  describe('Model find queries', function () {

    describe('.query()', function () {

      before(function () {
        return session.populate([{
          id: 1,
          model1Prop1: 'hello 1',
          model1Relation2: [{
            idCol: 1,
            model2Prop1: 'hejsan 1',