Skip to content

Latest commit

 

History

History
123 lines (83 loc) · 3.11 KB

README.md

File metadata and controls

123 lines (83 loc) · 3.11 KB

Query-Engine

A NoSQL (and MongoDB compliant) Query Engine coded in CoffeeScript for Server-Side use with Node.js and Client-Side use with Web-Browsers

Supported Queries

Query-Engine supports the exact same queries as MongoDb. Find the full listing of supported queries here.

You can find the test suite which showcases how to use the supported queries here.

You can try it out in real-time on the client side with a web browser here.

Installation

  • Server-Side with Node.js and CoffeeScript

    1. Install Node.js

    2. Install

       npm install query-engine
      
    3. Require

      queryEngine = require 'query-engine'
  • Client-Side with Web Browsers

    1. Download Query-Engine and upload it to your webserver

    2. Include lib/query-engine.js inside your page

      <script src="path/to/query-engine/lib/query-engine.js"></script>
    3. Utilise the window.queryEngine namespace

Using

  • Server-Side with Node.js and CoffeeScript

     # Collection
     documents = new queryEngine.Collection
     	0:
     		title: 'abc'
     		tags: ['a','b']
     	1:
     		title: 'blah'
     		tags: ['a','b','c']
    
     # Query
     documents.find tags: $in: ['a'] # {0: documents.0, 1: documents.1}
     documents.find title: 'blah' # {1: documents.1}
  • Client-Side with Web Browsers and JavaScript

     //Collection
     var documents = new window.queryEngine.Collection({
     	0: {
     		title: 'abc',
     		tags: ['a', 'b']
     	},
     	1: {
     		title: 'blah',
     		tags: ['a', 'b', 'c']
     	}
     });
    
     // Query
     documents.find({
     	tags: {
     		$in: ['a']
     	}
     }); // {0: documents.0, 1: documents.1}
     documents.find({
     	title: 'blah'
     }); // {1: documents.1}
  • You can also extend the native object prototype so queryEngine will work for all objects (not just collections) by doing:

     queryEngine.extendNatives()

History

  • v0.5.0 August 13, 2011

    • Added client side demo
    • Added queryEngine.Collection class so it doesn't extend the object prototype by default
      • If you would like to still extend the object prototype you can call queryEngine.extendNatives()
  • v0.4.0 August 13, 2011

    • Find will now return a ID associated object always
      • Before it was only doing it when the object we were finding was an ID associated object
    • Now supports $and, $or and $nor, as well as $type
  • v0.3.0 August 11, 2011

    • Now supports models as well as native javascript objects
      • This was done by checking if the record has a get function, if it does then we use that instead of directly accessing the field from the object
  • v0.2 July 6, 2011

    • Added toArray, sort, findOne, remove, forEach
  • v0.1 July 6, 2011

    • Initial commit

License

Licensed under the MIT License Copyright 2011 Benjamin Arthur Lupton