CrateJS
An extension to crate-connect, CrateJS will provide you with better methods for working with Crate.io.
Installation
npm install cratejs
Connecting
var Crate = ; //You can have as many db instance as you please :)//You should probably add this part to another module and export it!var db = moduleexports = host: 'localhost' port: 4200 /* Optional manual clustering cluster: [ { host: '192.168.0.100', port: 4200, } ] */;
- The "db" variable will be used in the examples below.
Sample docs
db.Select(tableName)
var findBars = db ; findBars;
db.Insert(tableName)
var insertBars = db; //Inserting a single rowinsertBarsdata bar: 1; //Inserting multiple rowsinsertBarsdata bar: 1 bar: 2 ;
db.Update(tableName)
var updateBars = db ; updateBars;
db.Delete(tableName)
var deleteBars = db ; deleteBars;
Methods inherited from crate-connect
db.Query(_queryString)
var getSomeTweets = db; var howMany = 10; getSomeTweets;
db.execute(_queryString)
db;
blob().put(table, sha1Hash, buffer, callback)
var buffer = 'sample'var hash = crypto ####
- Note that if the sha1 hash is not correct, the blob wont be inserted. The sha1 hash must be calculated from the blob to be inserted.
blob().get(table, sha1Hash, callback)
db
blob().check(table, sha1Hash, callback)
db
blob().delete(table, sha1Hash, callback)
db
TODO
- Blob helper
- Indexing helpers
- Shards and replicas helper
- Try out a binary connector
Contributors
This was created for the Crate.io data Storage.