Code Monkey home page Code Monkey logo

firestore-query-parser-js's Introduction

Firestore Query Parser JS

A JS (jison) parser for a textual SQL-like format for firestore query language

Build

npm install
make dist

Check dist folder

Test

Open test/index.html in your browser

Use

Try the Playground

Check test/tests.js for usage examples, but basically:

// return the query's AST
const ast = firestoreQueryParser.parse(
    'FROM "coll" WHERE a == false and b != true and c < 42 and d not-in [42, true, "hi"]'
)

// this
firestoreQueryParser.astToSExpr(ast);
// will return something like this, useful for debugging:
[
  ['collection', 'coll'],
  ['and',
    [
      ['where', ['a', '==', false]],
      ['where', ['b', '!=', true]],
      ['where', ['c', '<', 42]],
      ['where', ['d', 'not-in', [42, true, 'hi']]],
    ]
  ]
]

// this
firestoreQueryParser.astToPlan(ast);
// will return something like this, useful to apply it to the firestore query:
[
  ['collection', 'coll'],
  ['where', ['a', '==', false]],
  ['where', ['b', '!=', true]],
  ['where', ['c', '<', 42]],
  ['where', ['d', 'not-in', [42, true, 'hi']]],
]

// or you can just apply it to your query object:
firestoreQueryParser.applyToQuery(firestore, ast);

Author

Instadeq

License

MIT

firestore-query-parser-js's People

Contributors

marianoguerra avatar

Watchers

 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.