Coder Social home page Coder Social logo

advance-search's Introduction

Advance search:

This module help to build advance mongodb search queries.

Like........
EX.
(nodejs ANd php or angullar 4)
(nodejs or (java and (angular 2 or (reactjs and javascript))))
(nodejs and php or (java and php or (mongodb and typescript)))
(sql and (mongodb or (dynamodb oR (redis or dynamodb) or (mongodb and javascript))))

How to use it:

const gk = require('and-or-search');

Example: (Support collection array & string attributes)

  1. let res = gk.query('(nodejs AND (java or php))', 'skills', 'array');

  2. let res = gk.query('(tom or jon)', 'first_name', 'string');

-> 1st parameter is infix expression.
-> 2nd is the name of collection attribute.
-> 3rd is the type of collection attribute (array or string).

Pass the response query to mongodb for search.

let res = gk.query('(nodejs AND (java or php))', 'skills', 'array');

db.collection('user')
.find(res.query)
.then(result => {
//
}).catch(err => {
//
})

Response types:

{ message: "success", code: 200, query: [object] }
{ message: "Please provide expression to evaluate", code: 400, query: {} }

User collection:

{
"_id" : ObjectId("5c30e7c172fbebb2a8776d2c"),
"first_name" : "tom",
"last_name" : "PQR",
"skills" : [
"nodejs",
"php",
"mongodb"
],
"role" : "admin"
}

{
"_id" : ObjectId("5c30e82b72fbebb2a8776d45"),
"first_name" : "Jon",
"last_name" : "XYZ",
"skills" : [
"cordova",
"javascript",
"swift"
],
"role" : "admin"
}

advance-search's People

Contributors

ghatul avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.