mongo-to-knex

0.5.0 • Public • Published

mongo to knex

Applies mongo standard query to knex query builder.

Available operators

Checkout the available operators in the tests.

Installation

Install via npm:

$ npm install mongo-to-knex

Usage

var mongoToKnex = require('mongo-to-knex');
 
// knex main object
var knex = require('knex')({ /* knex config */ });
 
// knex query builder object
var knexQuery = knex('your-table-name');
 
// your query on mongo standard
var mongoQuery = { age: { $lt: 10 } };
 
// applies mongo query to knex builder
mongoToKnex(mongoQuery, knexQuery);
 
// continue using the knex query normally
return knexQuery.
  .limit(100)
  .orderBy('name', 'desc');

Contributing

It is required to use editorconfig and please write and run specs before pushing any changes:

npm test

License

Copyright (c) 2015 Max Claus Nunes. This software is licensed under the MIT License.

/mongo-to-knex/

    Package Sidebar

    Install

    npm i mongo-to-knex

    Weekly Downloads

    9

    Version

    0.5.0

    License

    none

    Last publish

    Collaborators

    • maxcnunes