So, yeah, it's not complete yet, but it can support simple queries and has an API similar to
var db = ;db;var esums = db;esums;esums;esums;var queryresults = esums;console;console;
If you're working on the client side, just include the script
higgle.js. This will provide you with the
Higgle object attached to the
On Node.js just require the module after installing it via NPM.
$ npm install higgle
// On Node.js you must require the module in order to use the Higgle objectvar Higgle = ;
Higgle is super simple. The
Higgle object represents your entire database. You can create an instance of one as follows:
var db = ; // It is common convention to name your database object 'db'
Within a database you can have one or more collections. Collections are a group of JSON documents. You can create a collection by calling the following method on your database object.
All you must specify as an argument is a string which will be the name of the collection. You can now grab a handle to the collection by calling the following method on your database object.
var people = db;
All you must specify as an argument is the name of the collection (the same name you used to create the collection). The variable
people is a collection object which you can utilize to modify your database.
Adding data is super simple. Just call the following method on the collection object and specify the JSON document you want to add to the collection.
The above code adds two JSON documents to the collection known as
Querying data is also super simple. Every query returns an array full of documents that matched the query. To perform a query call the following method on the collection object:
// This query will find all documents in the collection known as// 'people' that have the string 'wiley' paired with the key 'name'var queryresults = people;// You can also query with multiple JSON keysvar queryresults = people;
queryresults object is an array with all the JSON documents that matched the query.
Say for example we want to know all the people who can legally drink. To perform such a query we would do the following:
// Find all documents where the key of 'age' has a value greater than 21var queryresults = people;
Similarly, if we want to find all the documents in which the key of
age has a value that is less than 21 we could perform the following query:
// Find all documents where the key of 'age' has a value less than 21var queryresults = people;
Similarly, if we want to find documents with a key of
age that takes on a certain range of values, we can do so:
// Find all documents where the key of 'age' has a value in between 6 and 24var queryresults = people;