Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maxcnunes/mongo-to-knex
Applies a query like mongo standards to knex query builder
https://github.com/maxcnunes/mongo-to-knex
Last synced: 2 months ago
JSON representation
Applies a query like mongo standards to knex query builder
- Host: GitHub
- URL: https://github.com/maxcnunes/mongo-to-knex
- Owner: maxcnunes
- License: mit
- Created: 2015-05-21T23:26:17.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-05-18T21:03:01.000Z (over 4 years ago)
- Last Synced: 2024-10-19T09:51:14.079Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 17
- Watchers: 2
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mongo to knex
Applies mongo standard query to knex query builder.
## Available operators
Checkout the available operators in the [tests](https://github.com/maxcnunes/mongo-to-knex/blob/master/spec/mongo-to-knex.spec.js).
## Installation
Install via npm:
```bash
$ npm install mongo-to-knex
```## Usage
```js
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](http://editorconfig.org/) and please write and run specs before pushing any changes:
```js
npm test
```## License
Copyright (c) 2015 Max Claus Nunes. This software is licensed under the [MIT License](http://raw.github.com/maxcnunes/mongo-to-knex/master/LICENSE).