Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@zishone/monique

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zishone/monique

A middleware that utilized rsql-mongodb to parse url queries into mongodb filter and options. Who's monqique? It is not a who, it's just short for Mongo I Query.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

monique NPM Build Coverage License

A middleware that utilized rsql-mongodb to parse url queries into mongodb filter and options. Who's monique? It is not a who, it's just short for Mongo I Query.

Installation

$ npm i @zishone/monique

Usage

const express = require('express');
const { mquery } = require('@zishone/monique');
const MongoClient = require('mongodb').MongoClient;

const app = express();

// Use Middleware
app.use(mquery());
 
MongoClient.connect('mongodb://localhost:27017', (err, client) => {
  const db = client.db('myDB');

  app.get('/get', async (req, res) => {
    // FilterQuery and FindOneOptions should be available here
    const { filter, options } = req.mquery;

    const cursor = db.collection('myCollection').find(filter, options);
    const data = await cursor.toArray();

    res.send({ data });
  });

  app.listen(3000, () => {
    console.log('Listening at port 3000')
  })
});

Queries

  • filter
    • To filters list of objects.
    • Example:
      /get?filter=key==value
      
      More at rsql-mongodb
  • fields
    • To specify which fields of the objects to be returned.
    • Example:
      /get?fields=key1;key2
      
  • sort
    • To sort list of objects.
    • Example:
      /get?sort=key1==asc;key2==desc;key3
      
      Defaults to asc if not specified.
  • skip
    • To skip elements in list of objects.
    • Example:
      /get?skip=1
      
  • limit
    • To limit elements in list of objects.
    • Example:
      /get?limit=1
      
  • page
    • To skip elements in list of objects based on the given limit.
    • Example:
      /get?page=1&limit=10
      

Authors

  • Zishran Garces

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Keywords

FAQs

Package last updated on 27 Feb 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc