Socket
Socket
Sign inDemoInstall

mongo-query-builder-chain

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mongo-query-builder-chain

library for generating mongodb queries


Version published
Weekly downloads
2
Maintainers
1
Install size
9.63 kB
Created
Weekly downloads
 

Readme

Source

mongo-query-builder-chain

JS library for generating mongodb queries as chain easily.

usage

var mongoQBChain = require("mongo-query-builder-chain"); // load the library into a file

var mongoQuery = new mongoQBChain.MongoQuery(); // initialize an empty mongodb query

var mongoQuery = new mongoQBChain.MongoQuery({query: {field1: {$ne: "-1"}, field2: {$exists: true}, field3: 0}, sort: {"field1.field11.field111": 1, "field2.field21": 1, field4: -1}}); // initialize a mongodb query

mongoQuery.addToQuery(['field1', 'field11'], mongoQB.$ne("-1")) // adds field11 under field1 with {$ne: "-1"} value

mongoQuery.removeFromQuery(['field1']) // removes field1 along with its child field1 from the query

mongoQuery.sort("field1.field11", 1) // applies sort by asc on the child field11

mongoQuery.removeFromQuery(['field1']) // removes field1 along with its child field1 from the query

mongoQuery..getValue() // retrieves the whole body of the query

Keywords

FAQs

Last updated on 11 Apr 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc