@sidewinder/query
TypeScript icon, indicating that this package has built-in type declarations

0.13.0 • Public • Published

Sidewinder Query

Mongo Query Expressions

Overview

This package provides a query expression syntax for constructing mongo filters from JavaScript like expressions.

import { Query } from '@sidewinder/query'

const Q = Query(`
    user_id === '6364ed67a7e953d089dbe23d' && (
        record.name === 'foo' ||
        record.desc === 'bar'
    )
`)

// const Q = {
//   "$and": [
//     {
//       "user_id": "6364ed67a7e953d089dbe23d"
//     },
//     {
//       "$or": [
//         {
//           "record.name": "foo"
//         },
//         {
//           "record.desc": "bar"
//         }
//       ]
//     }
//   ]
// }

const results = await collection.find(Q).toArray()

Readme

Keywords

none

Package Sidebar

Install

npm i @sidewinder/query

Weekly Downloads

48

Version

0.13.0

License

MIT

Unpacked Size

74.7 kB

Total Files

43

Last publish

Collaborators

  • sinclair