From d5a964a5997c28170dc907ad91b80ea3cb049faa Mon Sep 17 00:00:00 2001 From: Jakub Dundalek Date: Sun, 6 Oct 2013 18:42:45 +0200 Subject: [PATCH] Generate API doc --- backend/base.js | 40 +- backend/elasticsearch.js | 27 +- backend/fs.js | 36 +- backend/local.js | 27 +- backend/memory.js | 31 +- backend/mongodb.js | 40 +- backend/nedb.js | 22 +- backend/rest.js | 27 +- backend/sql.js | 43 +- docs/api/BaseBackend.html | 495 ++++++++ docs/api/BaseStore.html | 1093 +++++++++++++++++ docs/api/ElasticSearchBackend.html | 508 ++++++++ docs/api/ElasticSearchStore.html | 619 ++++++++++ docs/api/FsBackend.html | 621 ++++++++++ docs/api/FsStore.html | 688 +++++++++++ docs/api/LocalBackend.html | 481 ++++++++ docs/api/LocalStore.html | 619 ++++++++++ docs/api/MemoryBackend.html | 481 ++++++++ docs/api/MemoryStore.html | 757 ++++++++++++ docs/api/MongoBackend.html | 676 ++++++++++ docs/api/MongoStore.html | 826 +++++++++++++ docs/api/NeBackend.html | 508 ++++++++ docs/api/NeStore.html | 826 +++++++++++++ docs/api/RestBackend.html | 508 ++++++++ docs/api/RestStore.html | 619 ++++++++++ docs/api/SqlBackend.html | 806 ++++++++++++ docs/api/SqlStore.html | 891 ++++++++++++++ docs/api/base.js.html | 229 ++++ docs/api/elasticsearch.js.html | 232 ++++ docs/api/fs.js.html | 203 +++ docs/api/index.html | 63 + docs/api/local.js.html | 170 +++ docs/api/memory.js.html | 197 +++ docs/api/module-base.html | 120 ++ docs/api/module-elasticsearch.html | 120 ++ docs/api/module-fs.html | 120 ++ docs/api/module-local.html | 120 ++ docs/api/module-memory.html | 120 ++ docs/api/module-mongodb.html | 120 ++ docs/api/module-nedb.html | 120 ++ docs/api/module-rest.html | 120 ++ docs/api/module-sql.html | 120 ++ docs/api/mongodb.js.html | 265 ++++ docs/api/nedb.js.html | 199 +++ docs/api/rest.js.html | 194 +++ docs/api/scripts/linenumber.js | 17 + .../scripts/prettify/Apache-License-2.0.txt | 202 +++ docs/api/scripts/prettify/lang-css.js | 2 + docs/api/scripts/prettify/prettify.js | 28 + docs/api/sql.js.html | 283 +++++ docs/api/styles/jsdoc-default.css | 290 +++++ docs/api/styles/prettify-jsdoc.css | 111 ++ docs/api/styles/prettify-tomorrow.css | 132 ++ make.coffee | 8 + package.json | 15 +- 55 files changed, 16111 insertions(+), 124 deletions(-) create mode 100644 docs/api/BaseBackend.html create mode 100644 docs/api/BaseStore.html create mode 100644 docs/api/ElasticSearchBackend.html create mode 100644 docs/api/ElasticSearchStore.html create mode 100644 docs/api/FsBackend.html create mode 100644 docs/api/FsStore.html create mode 100644 docs/api/LocalBackend.html create mode 100644 docs/api/LocalStore.html create mode 100644 docs/api/MemoryBackend.html create mode 100644 docs/api/MemoryStore.html create mode 100644 docs/api/MongoBackend.html create mode 100644 docs/api/MongoStore.html create mode 100644 docs/api/NeBackend.html create mode 100644 docs/api/NeStore.html create mode 100644 docs/api/RestBackend.html create mode 100644 docs/api/RestStore.html create mode 100644 docs/api/SqlBackend.html create mode 100644 docs/api/SqlStore.html create mode 100644 docs/api/base.js.html create mode 100644 docs/api/elasticsearch.js.html create mode 100644 docs/api/fs.js.html create mode 100644 docs/api/index.html create mode 100644 docs/api/local.js.html create mode 100644 docs/api/memory.js.html create mode 100644 docs/api/module-base.html create mode 100644 docs/api/module-elasticsearch.html create mode 100644 docs/api/module-fs.html create mode 100644 docs/api/module-local.html create mode 100644 docs/api/module-memory.html create mode 100644 docs/api/module-mongodb.html create mode 100644 docs/api/module-nedb.html create mode 100644 docs/api/module-rest.html create mode 100644 docs/api/module-sql.html create mode 100644 docs/api/mongodb.js.html create mode 100644 docs/api/nedb.js.html create mode 100644 docs/api/rest.js.html create mode 100644 docs/api/scripts/linenumber.js create mode 100644 docs/api/scripts/prettify/Apache-License-2.0.txt create mode 100644 docs/api/scripts/prettify/lang-css.js create mode 100644 docs/api/scripts/prettify/prettify.js create mode 100644 docs/api/sql.js.html create mode 100644 docs/api/styles/jsdoc-default.css create mode 100644 docs/api/styles/prettify-jsdoc.css create mode 100644 docs/api/styles/prettify-tomorrow.css create mode 100644 make.coffee diff --git a/backend/base.js b/backend/base.js index 61bfd5c..fa53b8e 100644 --- a/backend/base.js +++ b/backend/base.js @@ -1,4 +1,5 @@ +/** @module base */ (function (factory) { if (typeof module !== 'undefined' && typeof module.exports !== 'undefined' && typeof require !== 'undefined') { // CommonJS @@ -18,28 +19,32 @@ function BaseBackend() { _.extend(BaseBackend.prototype, /** @lends BaseBackend# */ { - /** */ + /** Initialize the backend instance */ initialize: function(options) { options = _.extend({}, options || {}); this.options = options; }, - /** */ + /** List storage names (e.g. tables for SQL, collections for MongoDB) + @abstract */ objectStoreNames: function() { }, - /** */ + /** Get object store + * @abstract */ objectStore: function(name, options) { }, - /** */ + /** Create object store + @abstract */ createObjectStore: function(name, options) { }, - /** */ + /** Delete object store + @abstract */ deleteObjectStore: function(name) { } @@ -55,7 +60,8 @@ function BaseStore() { _.extend(BaseStore.prototype, /** @lends BaseStore# */ { - /** */ + /** Initialize the backend instance + @constructs */ initialize: function(backend, name, options) { options = _.extend({keyPath: 'id'}, options || {}); this.options = options; @@ -65,36 +71,44 @@ _.extend(BaseStore.prototype, this.keyPath = this.options.keyPath; }, - /** */ + /** Get value (aka READ) + @abstract */ get: function(directives) { }, - /** */ + /** Add value (aka CREATE, insert) + @abstract */ add: function(object, directives) { }, - /** */ + /** Get value (aka UPDATE) + @abstract */ put: function(object, directives) { }, - /** */ + /** Delete value (aka DELETE) + @abstract */ 'delete': function(directives) { }, - /** Execute RQL query */ + /** Execute RQL query + @abstract */ query: function(query) { }, - /** Delete all items */ + /** Delete all items + @abstract */ clear: function() { }, + /** Extract key value from object + @private */ _getObjectKey: function(obj, key) { if (typeof key === 'object') { key = key.key; @@ -154,8 +168,10 @@ _.extend(BaseStore.prototype, return child; }; +/** Class inheritance */ BaseStore.extend = extend; +/** Class inheritance */ BaseBackend.extend = extend; BaseBackend.BaseStore = BaseStore; diff --git a/backend/elasticsearch.js b/backend/elasticsearch.js index 9598eb5..68c0bc7 100644 --- a/backend/elasticsearch.js +++ b/backend/elasticsearch.js @@ -1,4 +1,5 @@ +/** @module elasticsearch */ (function (factory) { var ajax, Q; if (typeof module !== 'undefined' && typeof module.exports !== 'undefined' && typeof require !== 'undefined') { @@ -37,11 +38,12 @@ } })(function(ajax, _, BaseBackend, rql2es) { -/** @class ElasticSearchBackend */ +/** @class ElasticSearchBackend + @extends BaseBackend */ var ElasticSearchBackend = BaseBackend.extend( /** @lends ElasticSearchBackend# */ { - /** */ + /** @method */ initialize: function(options) { options = _.extend({url: '/'}, options || {}); options.url = options.url.replace(/\/?$/, '/'); @@ -50,25 +52,25 @@ var ElasticSearchBackend = BaseBackend.extend( this.url = options.url; }, - // /** */ + // /** @method */ // objectStoreNames: function() { // return Q.defer() // .resolve(_.keys(this._stores)); // }, - /** */ + /** @method */ objectStore: function(name, options) { var url = this.url + name; return new ElasticSearchStore(this, name, url, options); }, - // /** */ + // /** @method */ // createObjectStore: function(name, options) { // return Q.defer() // .resolve(this.objectStore(name, options)); // }, - // /** */ + // /** @method */ // deleteObjectStore: function(name) { // return Q.defer() // .resolve(delete this._stores[name]); @@ -77,11 +79,12 @@ var ElasticSearchBackend = BaseBackend.extend( -/** @class ElasticSearchStore */ +/** @class ElasticSearchStore + @extends BaseStore */ var ElasticSearchStore = BaseBackend.BaseStore.extend( /** @lends ElasticSearchStore# */ { - /** */ + /** @method */ initialize: function(backend, name, url, options) { options = _.extend({keyPath: '_id'}, options || {}); BaseBackend.BaseStore.prototype.initialize.call(this, backend, name, options); @@ -89,7 +92,7 @@ var ElasticSearchStore = BaseBackend.BaseStore.extend( this._url = url; }, - /** */ + /** @method */ get: function(directives) { var key = this._getObjectKey({}, directives); @@ -99,12 +102,12 @@ var ElasticSearchStore = BaseBackend.BaseStore.extend( }); }, - /** */ + /** @method */ add: function(object, directives) { return ElasticSearchStore.prototype.put.call(this, object, directives); }, - /** */ + /** @method */ put: function(object, directives) { object = _.clone(object); var self = this; @@ -136,7 +139,7 @@ var ElasticSearchStore = BaseBackend.BaseStore.extend( }); }, - /** */ + /** @method */ 'delete': function(directives) { var key = this._getObjectKey({}, directives); diff --git a/backend/fs.js b/backend/fs.js index 8b4bbc2..288141e 100644 --- a/backend/fs.js +++ b/backend/fs.js @@ -10,27 +10,28 @@ function resolvedPromise(val) { return d.promise; } -/** @class FsBackend */ +/** @class FsBackend + @extends BaseBackend */ var FsBackend = BaseBackend.extend( /** @lends FsBackend# */ { - /** */ + /** @method */ initialize: function(options) { BaseBackend.prototype.initialize.call(this, options); }, - /** */ + /** @method */ objectStoreNames: function() { return Q.ninvoke(fs, 'readdir', this.options.path); }, - /** */ + /** @method */ objectStore: function(name, options) { name = path.basename(name); return new FsStore(this, name, options); }, - /** */ + /** @method */ createObjectStore: function(name, options) { var d = Q.defer(); name = path.basename(name); @@ -40,29 +41,36 @@ var FsBackend = BaseBackend.extend( return d.promise; }, - /** */ + /** @method */ deleteObjectStore: function(name) { name = path.basename(name); this.objectStore(name).clear().then(function() { return Q.ninvoke(fs, 'rmdir', path.join(this.options.path, name)); }); }, + /** Encode object into string, by default uses JSON.stringify + Override to use different serialization + @method */ encode: JSON.stringify, + /** Decode string into object, by default uses JSON.parse + Override to use different serialization + @method */ decode: JSON.parse }); -/** @class FsStore */ +/** @class FsStore + @extends BaseStore */ var FsStore = BaseBackend.BaseStore.extend( /** @lends FsStore# */ { - /** */ + /** @method */ initialize: function(backend, name, options) { BaseBackend.BaseStore.prototype.initialize.call(this, backend, name, options); }, - /** */ + /** @method */ get: function(directives) { var key = this._getObjectKey({}, directives); return Q.ninvoke(fs, 'readFile', this.filename(key), 'utf-8') @@ -71,7 +79,7 @@ var FsStore = BaseBackend.BaseStore.extend( }.bind(this)); }, - /** */ + /** @method */ add: function(object, directives) { var key = this._getObjectKey(object, directives); @@ -80,7 +88,7 @@ var FsStore = BaseBackend.BaseStore.extend( }); }, - /** */ + /** @method */ put: function(object, directives) { var key = this._getObjectKey(object, directives); @@ -89,7 +97,7 @@ var FsStore = BaseBackend.BaseStore.extend( }); }, - /** */ + /** @method */ 'delete': function(directives) { var key = this._getObjectKey({}, directives), d = Q.defer(); @@ -133,11 +141,13 @@ var FsStore = BaseBackend.BaseStore.extend( }); }, + /** Get absolute filename for given key */ filename: function(file) { - return path.join(this.backend.options.path, this.name, ''+path.basename(file)); } }); +/** @module fs */ + FsBackend.FsStore = FsStore; module.exports = FsBackend; diff --git a/backend/local.js b/backend/local.js index 343d1fb..3bedcc7 100644 --- a/backend/local.js +++ b/backend/local.js @@ -1,4 +1,5 @@ +/** @module local */ (function (factory) { // if (typeof module !== 'undefined' && typeof module.exports !== 'undefined' && typeof require !== 'undefined') { // // CommonJS @@ -16,11 +17,12 @@ function resolvedPromise(val) { return d.promise; } -/** @class LocalBackend */ +/** @class LocalBackend + @extends BaseBackend */ var LocalBackend = BaseBackend.extend( /** @lends LocalBackend# */ { - /** */ + /** @method */ initialize: function(options) { BaseBackend.prototype.initialize.call(this, options); @@ -29,22 +31,22 @@ var LocalBackend = BaseBackend.extend( } }, - /** */ + /** @method */ objectStoreNames: function() { return ['local', 'session']; }, - /** */ + /** @method */ objectStore: function(name, options) { return new LocalStore(this, name, options); }, - /** */ + /** @method */ createObjectStore: function(name, options) { return resolvedPromise(this.objectStore(name, options)); }, - /** */ + /** @method */ deleteObjectStore: function(name) { return resolvedPromise(this.objectStore(name).clear()); } @@ -52,30 +54,31 @@ var LocalBackend = BaseBackend.extend( -/** @class LocalStore */ +/** @class LocalStore + @extends BaseStore */ var LocalStore = BaseBackend.BaseStore.extend( /** @lends LocalStore# */ { - /** */ + /** @method */ initialize: function(backend, name, options) { BaseBackend.BaseStore.prototype.initialize.call(this, backend, name, options); this._store = name === 'session' ? sessionStorage : localStorage; }, - /** */ + /** @method */ get: function(directives) { var key = this._getObjectKey({}, directives); return resolvedPromise(JSON.parse(this._store.getItem(key))); }, - /** */ + /** @method */ add: function(object, directives) { return this.put(object, directives); }, - /** */ + /** @method */ put: function(object, directives) { object = _.clone(object); var key = this._getObjectKey(object, directives); @@ -85,7 +88,7 @@ var LocalStore = BaseBackend.BaseStore.extend( return resolvedPromise(object); }, - /** */ + /** @method */ 'delete': function(directives) { var key = this._getObjectKey({}, directives); diff --git a/backend/memory.js b/backend/memory.js index a7d76ea..1fabbc0 100644 --- a/backend/memory.js +++ b/backend/memory.js @@ -1,4 +1,5 @@ +/** @module memory */ (function (factory) { if (typeof module !== 'undefined' && typeof module.exports !== 'undefined' && typeof require !== 'undefined') { // CommonJS @@ -16,23 +17,24 @@ function resolvedPromise(val) { return d.promise; } -/** @class MemoryBackend */ +/** @class MemoryBackend + @extends BaseBackend */ var MemoryBackend = BaseBackend.extend( /** @lends MemoryBackend# */ { - /** */ + /** @method */ initialize: function(options) { BaseBackend.prototype.initialize.call(this, options); this._stores = {}; }, - /** */ + /** @method */ objectStoreNames: function() { return resolvedPromise(_.keys(this._stores)); }, - /** */ + /** @method */ objectStore: function(name, options) { if (!this._stores[name]) { this._stores[name] = []; @@ -40,12 +42,12 @@ var MemoryBackend = BaseBackend.extend( return new MemoryStore(this, name, this._stores[name], options); }, - /** */ + /** @method */ createObjectStore: function(name, options) { return resolvedPromise(this.objectStore(name, options)); }, - /** */ + /** @method */ deleteObjectStore: function(name) { return resolvedPromise(delete this._stores[name]); } @@ -53,25 +55,26 @@ var MemoryBackend = BaseBackend.extend( -/** @class MemoryStore */ +/** @class MemoryStore + @extends BaseStore */ var MemoryStore = BaseBackend.BaseStore.extend( /** @lends MemoryStore# */ { - /** */ + /** @method */ initialize: function(backend, name, store, options) { BaseBackend.BaseStore.prototype.initialize.call(this, backend, name, options); this.fromJSON(options.json); }, - /** */ + /** @method */ get: function(directives) { var key = this._getObjectKey({}, directives); return resolvedPromise(this._store[key]); }, - /** */ + /** @method */ add: function(object, directives) { object = _.clone(object); var key = this._getObjectKey(object, directives); @@ -81,7 +84,7 @@ var MemoryStore = BaseBackend.BaseStore.extend( return resolvedPromise(object); }, - /** */ + /** @method */ put: function(object, directives) { object = _.clone(object); var key = this._getObjectKey(object, directives); @@ -91,7 +94,7 @@ var MemoryStore = BaseBackend.BaseStore.extend( return resolvedPromise(object); }, - /** */ + /** @method */ 'delete': function(directives) { var key = this._getObjectKey({}, directives); @@ -112,7 +115,7 @@ var MemoryStore = BaseBackend.BaseStore.extend( return resolvedPromise(true); }, - /** */ + /** Sets data to be used */ fromJSON: function(data) { var ret = {}; if (typeof data === 'string') { @@ -133,7 +136,7 @@ var MemoryStore = BaseBackend.BaseStore.extend( this._store = ret; }, - /** */ + /** Returns copy of all data */ toJSON: function() { return _.clone(this._store); } diff --git a/backend/mongodb.js b/backend/mongodb.js index 4c165a6..a1c65bb 100644 --- a/backend/mongodb.js +++ b/backend/mongodb.js @@ -8,11 +8,12 @@ var Db = require('mongodb').Db, -/** @class MongoBackend */ +/** @class MongoBackend + @extends BaseBackend */ var MongoBackend = BaseBackend.extend( /** @lends MongoBackend# */ { - /** */ + /** @method */ initialize: function(options) { options = _.extend({}, MongoBackend.defaults, options || {}); this.options = options; @@ -22,19 +23,19 @@ var MongoBackend = BaseBackend.extend( this._opened = null; }, - /** */ + /** @method */ objectStoreNames: function() { return this.open().then(function(db) { return Q.ninvoke(db, 'collectionNames'); }); }, - /** */ + /** @method */ objectStore: function(name, options) { return new MongoStore(this, name, options); }, - /** */ + /** @method */ createObjectStore: function(name, options) { return this.open().then(function(db) { return Q.ninvoke(db, 'collection', name).then(function() { @@ -43,14 +44,14 @@ var MongoBackend = BaseBackend.extend( }); }, - /** */ + /** @method */ deleteObjectStore: function(name) { return this.open().then(function(db) { return Q.ninvoke(db, 'dropCollection', name); }); }, - /** */ + /** @method */ open: function() { var self = this; if (!this._opened) { @@ -69,7 +70,7 @@ var MongoBackend = BaseBackend.extend( return this._opened; }, - /** */ + /** @method */ close: function() { if (this._opened) { this._opened = false; @@ -77,7 +78,7 @@ var MongoBackend = BaseBackend.extend( } }, - /** */ + /** @method */ isClosed: function() { return Q.defer() .resolve(!!this._opened); @@ -90,11 +91,12 @@ MongoBackend.defaults = { database: 'default' }; -/** @class MongoStore */ +/** @class MongoStore + @extends BaseStore */ var MongoStore = BaseBackend.BaseStore.extend( /** @lends MongoStore# */ { - /** */ + /** @method */ initialize: function(backend, name, options) { options = _.extend({keyPath: '_id'}, options || {}); BaseBackend.BaseStore.prototype.initialize.call(this, backend, name, options); @@ -102,7 +104,7 @@ var MongoStore = BaseBackend.BaseStore.extend( this._collection = null; }, - /** */ + /** @method */ get: function(directives) { var search = {}; search[this.keyPath] = this._getObjectKey({}, directives); @@ -111,7 +113,7 @@ var MongoStore = BaseBackend.BaseStore.extend( }); }, - /** */ + /** @method */ add: function(object, directives) { //var key = this._getObjectKey(object, directives); @@ -123,7 +125,7 @@ var MongoStore = BaseBackend.BaseStore.extend( }); }, - /** */ + /** @method */ put: function(object, directives) { var key = this._getObjectKey(object, directives), selector = {}; @@ -136,7 +138,7 @@ var MongoStore = BaseBackend.BaseStore.extend( }); }, - /** */ + /** @method */ 'delete': function(directives) { var search = {}; search[this.keyPath] = this._getObjectKey({}, directives); @@ -186,14 +188,12 @@ var MongoStore = BaseBackend.BaseStore.extend( }); }, - /** - * Parse RQL query - * @function - */ + /** Parse RQL query */ parse: function(query) { return _.rql(query).toMongo(); }, + /* @method */ _getObjectKey: function(obj, key) { if (typeof key === 'object') { key = key.key; @@ -210,5 +210,7 @@ var MongoStore = BaseBackend.BaseStore.extend( } }); +/** @module mongodb */ + MongoBackend.MongoStore = MongoStore; module.exports = MongoBackend; \ No newline at end of file diff --git a/backend/nedb.js b/backend/nedb.js index f457dd2..8e78315 100644 --- a/backend/nedb.js +++ b/backend/nedb.js @@ -6,28 +6,30 @@ var Datastore = require('nedb'), -/** @class NeBackend */ +/** @class NeBackend + @extends BaseBackend */ var NeBackend = BaseBackend.extend( /** @lends NeBackend# */ { - /** */ + /** @method */ initialize: function(options) { options = options || {}; this.options = options; }, - /** */ + /** @method */ objectStore: function(name, options) { return new NeStore(this, name, options); } }); -/** @class NeStore */ +/** @class NeStore + @extends BaseStore */ var NeStore = BaseBackend.BaseStore.extend( /** @lends NeStore# */ { - /** */ + /** @method */ initialize: function(backend, name, options) { options = _.extend({keyPath: 'id'}, options || {}); BaseBackend.BaseStore.prototype.initialize.call(this, backend, name, options); @@ -38,7 +40,7 @@ var NeStore = BaseBackend.BaseStore.extend( }); }, - /** */ + /** @method */ get: function(directives) { var search = {}; search[this.keyPath] = this._getObjectKey({}, directives); @@ -47,7 +49,7 @@ var NeStore = BaseBackend.BaseStore.extend( }); }, - /** */ + /** @method */ add: function(object, directives) { //var key = this._getObjectKey(object, directives); @@ -59,7 +61,7 @@ var NeStore = BaseBackend.BaseStore.extend( }); }, - /** */ + /** @method */ put: function(object, directives) { var key = this._getObjectKey(object, directives), selector = {}; @@ -72,7 +74,7 @@ var NeStore = BaseBackend.BaseStore.extend( }); }, - /** */ + /** @method */ 'delete': function(directives) { var search = {}; search[this.keyPath] = this._getObjectKey({}, directives); @@ -142,5 +144,7 @@ var NeStore = BaseBackend.BaseStore.extend( } }); +/** @module nedb */ + NeBackend.NeStore = NeStore; module.exports = NeBackend; \ No newline at end of file diff --git a/backend/rest.js b/backend/rest.js index 5ee41f5..72517b7 100644 --- a/backend/rest.js +++ b/backend/rest.js @@ -1,4 +1,5 @@ +/** @module rest */ (function (factory) { var ajax, Q; if (typeof module !== 'undefined' && typeof module.exports !== 'undefined' && typeof require !== 'undefined') { @@ -37,11 +38,12 @@ } })(function(ajax, _, BaseBackend) { -/** @class RestBackend */ +/** @class RestBackend + @extends BaseBackend */ var RestBackend = BaseBackend.extend( /** @lends RestBackend# */ { - /** */ + /** @method */ initialize: function(options) { options = _.extend({url: '/'}, options || {}); options.url = options.url.replace(/\/?$/, '/'); @@ -50,25 +52,25 @@ var RestBackend = BaseBackend.extend( this.url = options.url; }, - // /** */ + // /** @method */ // objectStoreNames: function() { // return Q.defer() // .resolve(_.keys(this._stores)); // }, - /** */ + /** @method */ objectStore: function(name, options) { var url = this.url + name; return new RestStore(this, name, url, options); }, - // /** */ + // /** @method */ // createObjectStore: function(name, options) { // return Q.defer() // .resolve(this.objectStore(name, options)); // }, - // /** */ + // /** @method */ // deleteObjectStore: function(name) { // return Q.defer() // .resolve(delete this._stores[name]); @@ -77,25 +79,26 @@ var RestBackend = BaseBackend.extend( -/** @class RestStore */ +/** @class RestStore + @extends BaseStore */ var RestStore = BaseBackend.BaseStore.extend( /** @lends RestStore# */ { - /** */ + /** @method */ initialize: function(backend, name, url, options) { BaseBackend.BaseStore.prototype.initialize.call(this, backend, name, options); this._url = url; }, - /** */ + /** @method */ get: function(directives) { var key = this._getObjectKey({}, directives); return ajax('GET', this._url+'/' + key); }, - /** */ + /** @method */ add: function(object, directives) { object = _.clone(object); // var key = this._getObjectKey(object, directives); @@ -106,7 +109,7 @@ var RestStore = BaseBackend.BaseStore.extend( return ajax('POST', this._url, object); }, - /** */ + /** @method */ put: function(object, directives) { object = _.clone(object); var key = this._getObjectKey(object, directives); @@ -117,7 +120,7 @@ var RestStore = BaseBackend.BaseStore.extend( return ajax('PUT', this._url + '/' + key, object); }, - /** */ + /** @method */ 'delete': function(directives) { var key = this._getObjectKey({}, directives); diff --git a/backend/sql.js b/backend/sql.js index e6a6d2b..5802a95 100644 --- a/backend/sql.js +++ b/backend/sql.js @@ -6,11 +6,12 @@ var persist = require('persist'), BaseBackend = require('./base'), rql = require('../rql/sql'); -/** @class SqlBackend */ +/** @class SqlBackend + @extends BaseBackend */ var SqlBackend = BaseBackend.extend( /** @lends SqlBackend# */ { - /** */ + /** @method */ initialize: function(options) { options = _.extend({driver: 'mysql'}, SqlBackend.defaults, options || {}); this.options = options; @@ -18,7 +19,7 @@ var SqlBackend = BaseBackend.extend( this._opened = null; }, - /** */ + /** @method */ objectStoreNames: function() { var sql = (this.options.driver === 'sqlite3') ? "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;" @@ -26,22 +27,22 @@ var SqlBackend = BaseBackend.extend( return this.runSqlAll(sql); }, - /** */ + /** @method */ objectStore: function(name, options) { return new SqlStore(this, name, options); }, - /** */ + /** @method */ createObjectStore: function(name, options) { throw 'Not implemented - please use CREATE TABLE query'; }, - /** */ + /** @method */ deleteObjectStore: function(name) { return this.runSql('DROP TABLE ' + SqlStore.prototype.escapeIdentifier(name)); }, - /** */ + /** @method */ open: function() { if (!this._opened) { this._opened = Q.ninvoke(persist, 'connect', this.options); @@ -49,25 +50,25 @@ var SqlBackend = BaseBackend.extend( return this._opened; }, - /** */ + /** @method */ close: function() { throw 'Not implemented!'; }, - /** */ + /** @method */ isClosed: function() { return Q.defer() .resolve(!!this._opened); }, - /** */ + /** @method */ runSql: function(sql, values) { return this.open().then(function(connection) { return Q.ninvoke(connection, 'runSql', sql, values||[]); }); }, - /** */ + /** @method */ runSqlAll: function(sql, values) { return this.open().then(function(connection) { return Q.ninvoke(connection, 'runSqlAll', sql, values||[]); @@ -82,11 +83,12 @@ SqlBackend.defaults = { }; -/** @class SqlStore */ +/** @class SqlStore + @extends BaseStore */ var SqlStore = BaseBackend.BaseStore.extend( /** @lends SqlStore# */ { - /** */ + /** @method */ get: function(directives) { var key = this._getObjectKey({}, directives), sql = util.format('SELECT * FROM %s WHERE %s = ?;', @@ -99,7 +101,7 @@ var SqlStore = BaseBackend.BaseStore.extend( }); }, - /** */ + /** @method */ add: function(object, directives) { var args = [], placeholders = [], @@ -129,7 +131,7 @@ var SqlStore = BaseBackend.BaseStore.extend( }); }, - /** */ + /** @method */ put: function(object, directives) { var key = this._getObjectKey(object, directives), args = [], @@ -153,7 +155,7 @@ var SqlStore = BaseBackend.BaseStore.extend( }); }, - /** */ + /** @method */ 'delete': function(directives) { var key = this._getObjectKey({}, directives), sql = util.format('DELETE FROM %s WHERE %s = ?;', @@ -200,15 +202,16 @@ var SqlStore = BaseBackend.BaseStore.extend( return this.runSql(sql); }, - /** Escape table or column name */ + /** Escape table or column name + @method */ escapeIdentifier: rql.sqlEscapeIdentifier, - /** */ + /** @method */ runSql: function(sql, values) { return this.backend.runSql(sql, values); }, - /** */ + /** @method */ runSqlAll: function(sql, values) { return this.backend.runSqlAll(sql, values); }, @@ -222,6 +225,8 @@ var SqlStore = BaseBackend.BaseStore.extend( } }); +/** @module sql */ + SqlBackend.SqlStore = SqlStore; SqlBackend.rql2sql = rql.rql2sql; diff --git a/docs/api/BaseBackend.html b/docs/api/BaseBackend.html new file mode 100644 index 0000000..0b8d01e --- /dev/null +++ b/docs/api/BaseBackend.html @@ -0,0 +1,495 @@ + + + + + JSDoc: Class: BaseBackend + + + + + + + + + + +
+ +

Class: BaseBackend

+ + + + + +
+ +
+

+ BaseBackend +

+ +
+ +
+
+ + + + +
+

new BaseBackend()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+

<abstract> createObjectStore()

+ + +
+
+ + +
+ Create object store +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<abstract> deleteObjectStore()

+ + +
+
+ + +
+ Delete object store +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

initialize()

+ + +
+
+ + +
+ Initialize the backend instance +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<abstract> objectStore()

+ + +
+
+ + +
+ Get object store +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<abstract> objectStoreNames()

+ + +
+
+ + +
+ List storage names (e.g. tables for SQL, collections for MongoDB) +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/BaseStore.html b/docs/api/BaseStore.html new file mode 100644 index 0000000..825ff99 --- /dev/null +++ b/docs/api/BaseStore.html @@ -0,0 +1,1093 @@ + + + + + JSDoc: Class: BaseStore + + + + + + + + + + +
+ +

Class: BaseStore

+ + + + + +
+ +
+

+ BaseStore +

+ +
+ +
+
+ + + + +
+

new BaseStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+

<abstract> add()

+ + +
+
+ + +
+ Add value (aka CREATE, insert) +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<abstract> clear()

+ + +
+
+ + +
+ Delete all items +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<abstract> delete()

+ + +
+
+ + +
+ Delete value (aka DELETE) +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<abstract> get()

+ + +
+
+ + +
+ Get value (aka READ) +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<abstract> put()

+ + +
+
+ + +
+ Get value (aka UPDATE) +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<abstract> query()

+ + +
+
+ + +
+ Execute RQL query +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + + + +
+ +
+

+ BaseStore +

+ +
+ +
+
+ + + + +
+

new BaseStore()

+ + +
+
+ + +
+ Initialize the backend instance +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ +
+

<abstract> add()

+ + +
+
+ + +
+ Add value (aka CREATE, insert) +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<abstract> clear()

+ + +
+
+ + +
+ Delete all items +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<abstract> delete()

+ + +
+
+ + +
+ Delete value (aka DELETE) +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<abstract> get()

+ + +
+
+ + +
+ Get value (aka READ) +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<abstract> put()

+ + +
+
+ + +
+ Get value (aka UPDATE) +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<abstract> query()

+ + +
+
+ + +
+ Execute RQL query +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/ElasticSearchBackend.html b/docs/api/ElasticSearchBackend.html new file mode 100644 index 0000000..93ebf7b --- /dev/null +++ b/docs/api/ElasticSearchBackend.html @@ -0,0 +1,508 @@ + + + + + JSDoc: Class: ElasticSearchBackend + + + + + + + + + + +
+ +

Class: ElasticSearchBackend

+ + + + + +
+ +
+

+ ElasticSearchBackend +

+ +
+ +
+
+ + + + +
+

new ElasticSearchBackend()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + +

Methods

+ +
+ +
+

<abstract> createObjectStore()

+ + +
+
+ + +
+ Create object store +
+ + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<abstract> deleteObjectStore()

+ + +
+
+ + +
+ Delete object store +
+ + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

initialize()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

objectStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<abstract> objectStoreNames()

+ + +
+
+ + +
+ List storage names (e.g. tables for SQL, collections for MongoDB) +
+ + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/ElasticSearchStore.html b/docs/api/ElasticSearchStore.html new file mode 100644 index 0000000..f1cfbac --- /dev/null +++ b/docs/api/ElasticSearchStore.html @@ -0,0 +1,619 @@ + + + + + JSDoc: Class: ElasticSearchStore + + + + + + + + + + +
+ +

Class: ElasticSearchStore

+ + + + + +
+ +
+

+ ElasticSearchStore +

+ +
+ +
+
+ + + + +
+

new ElasticSearchStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + +

Methods

+ +
+ +
+

add()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

clear()

+ + +
+
+ + +
+ Delete all items +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

delete()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

get()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

initialize()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

put()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

query()

+ + +
+
+ + +
+ Execute RQL query +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/FsBackend.html b/docs/api/FsBackend.html new file mode 100644 index 0000000..5e21a0c --- /dev/null +++ b/docs/api/FsBackend.html @@ -0,0 +1,621 @@ + + + + + JSDoc: Class: FsBackend + + + + + + + + + + +
+ +

Class: FsBackend

+ + + + + +
+ +
+

+ FsBackend +

+ +
+ +
+
+ + + + +
+

new FsBackend()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + +

Methods

+ +
+ +
+

createObjectStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

decode()

+ + +
+
+ + +
+ Decode string into object, by default uses JSON.parse + Override to use different serialization +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

deleteObjectStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

encode()

+ + +
+
+ + +
+ Encode object into string, by default uses JSON.stringify + Override to use different serialization +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

initialize()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

objectStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

objectStoreNames()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/FsStore.html b/docs/api/FsStore.html new file mode 100644 index 0000000..5d231a5 --- /dev/null +++ b/docs/api/FsStore.html @@ -0,0 +1,688 @@ + + + + + JSDoc: Class: FsStore + + + + + + + + + + +
+ +

Class: FsStore

+ + + + + +
+ +
+

+ FsStore +

+ +
+ +
+
+ + + + +
+

new FsStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + +

Methods

+ +
+ +
+

add()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

clear()

+ + +
+
+ + +
+ Delete all items +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

delete()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

filename()

+ + +
+
+ + +
+ Get absolute filename for given key +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

get()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

initialize()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

put()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

query()

+ + +
+
+ + +
+ Execute RQL query +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/LocalBackend.html b/docs/api/LocalBackend.html new file mode 100644 index 0000000..79b7975 --- /dev/null +++ b/docs/api/LocalBackend.html @@ -0,0 +1,481 @@ + + + + + JSDoc: Class: LocalBackend + + + + + + + + + + +
+ +

Class: LocalBackend

+ + + + + +
+ +
+

+ LocalBackend +

+ +
+ +
+
+ + + + +
+

new LocalBackend()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + +

Methods

+ +
+ +
+

createObjectStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

deleteObjectStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

initialize()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

objectStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

objectStoreNames()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/LocalStore.html b/docs/api/LocalStore.html new file mode 100644 index 0000000..8553414 --- /dev/null +++ b/docs/api/LocalStore.html @@ -0,0 +1,619 @@ + + + + + JSDoc: Class: LocalStore + + + + + + + + + + +
+ +

Class: LocalStore

+ + + + + +
+ +
+

+ LocalStore +

+ +
+ +
+
+ + + + +
+

new LocalStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + +

Methods

+ +
+ +
+

add()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

clear()

+ + +
+
+ + +
+ Delete all items +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

delete()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

get()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

initialize()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

put()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

query()

+ + +
+
+ + +
+ Execute RQL query +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/MemoryBackend.html b/docs/api/MemoryBackend.html new file mode 100644 index 0000000..89aac8c --- /dev/null +++ b/docs/api/MemoryBackend.html @@ -0,0 +1,481 @@ + + + + + JSDoc: Class: MemoryBackend + + + + + + + + + + +
+ +

Class: MemoryBackend

+ + + + + +
+ +
+

+ MemoryBackend +

+ +
+ +
+
+ + + + +
+

new MemoryBackend()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + +

Methods

+ +
+ +
+

createObjectStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

deleteObjectStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

initialize()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

objectStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

objectStoreNames()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/MemoryStore.html b/docs/api/MemoryStore.html new file mode 100644 index 0000000..bc0ca3b --- /dev/null +++ b/docs/api/MemoryStore.html @@ -0,0 +1,757 @@ + + + + + JSDoc: Class: MemoryStore + + + + + + + + + + +
+ +

Class: MemoryStore

+ + + + + +
+ +
+

+ MemoryStore +

+ +
+ +
+
+ + + + +
+

new MemoryStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + +

Methods

+ +
+ +
+

add()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

clear()

+ + +
+
+ + +
+ Delete all items +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

delete()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

fromJSON()

+ + +
+
+ + +
+ Sets data to be used +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

get()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

initialize()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

put()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

query()

+ + +
+
+ + +
+ Execute RQL query +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

toJSON()

+ + +
+
+ + +
+ Returns copy of all data +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/MongoBackend.html b/docs/api/MongoBackend.html new file mode 100644 index 0000000..5db41d4 --- /dev/null +++ b/docs/api/MongoBackend.html @@ -0,0 +1,676 @@ + + + + + JSDoc: Class: MongoBackend + + + + + + + + + + +
+ +

Class: MongoBackend

+ + + + + +
+ +
+

+ MongoBackend +

+ +
+ +
+
+ + + + +
+

new MongoBackend()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + +

Methods

+ +
+ +
+

close()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

createObjectStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

deleteObjectStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

initialize()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

isClosed()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

objectStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

objectStoreNames()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

open()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/MongoStore.html b/docs/api/MongoStore.html new file mode 100644 index 0000000..28a7db0 --- /dev/null +++ b/docs/api/MongoStore.html @@ -0,0 +1,826 @@ + + + + + JSDoc: Class: MongoStore + + + + + + + + + + +
+ +

Class: MongoStore

+ + + + + +
+ +
+

+ MongoStore +

+ +
+ +
+
+ + + + +
+

new MongoStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + +

Methods

+ +
+ +
+

add()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

clear()

+ + +
+
+ + +
+ Delete all items +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

collection()

+ + +
+
+ + +
+ Get Collection object +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

db()

+ + +
+
+ + +
+ Get native DB object +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

delete()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

get()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

initialize()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

parse()

+ + +
+
+ + +
+ Parse RQL query +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

put()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

query()

+ + +
+
+ + +
+ Execute RQL query +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/NeBackend.html b/docs/api/NeBackend.html new file mode 100644 index 0000000..94467c3 --- /dev/null +++ b/docs/api/NeBackend.html @@ -0,0 +1,508 @@ + + + + + JSDoc: Class: NeBackend + + + + + + + + + + +
+ +

Class: NeBackend

+ + + + + +
+ +
+

+ NeBackend +

+ +
+ +
+
+ + + + +
+

new NeBackend()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + +

Methods

+ +
+ +
+

<abstract> createObjectStore()

+ + +
+
+ + +
+ Create object store +
+ + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<abstract> deleteObjectStore()

+ + +
+
+ + +
+ Delete object store +
+ + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

initialize()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

objectStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<abstract> objectStoreNames()

+ + +
+
+ + +
+ List storage names (e.g. tables for SQL, collections for MongoDB) +
+ + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/NeStore.html b/docs/api/NeStore.html new file mode 100644 index 0000000..2b71481 --- /dev/null +++ b/docs/api/NeStore.html @@ -0,0 +1,826 @@ + + + + + JSDoc: Class: NeStore + + + + + + + + + + +
+ +

Class: NeStore

+ + + + + +
+ +
+

+ NeStore +

+ +
+ +
+
+ + + + +
+

new NeStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + +

Methods

+ +
+ +
+

add()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

clear()

+ + +
+
+ + +
+ Delete all items +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

collection()

+ + +
+
+ + +
+ Get Collection object +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

db()

+ + +
+
+ + +
+ Get native DB object +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

delete()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

get()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

initialize()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

parse()

+ + +
+
+ + +
+ Parse RQL query +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

put()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

query()

+ + +
+
+ + +
+ Execute RQL query +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/RestBackend.html b/docs/api/RestBackend.html new file mode 100644 index 0000000..8b38e33 --- /dev/null +++ b/docs/api/RestBackend.html @@ -0,0 +1,508 @@ + + + + + JSDoc: Class: RestBackend + + + + + + + + + + +
+ +

Class: RestBackend

+ + + + + +
+ +
+

+ RestBackend +

+ +
+ +
+
+ + + + +
+

new RestBackend()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + +

Methods

+ +
+ +
+

<abstract> createObjectStore()

+ + +
+
+ + +
+ Create object store +
+ + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<abstract> deleteObjectStore()

+ + +
+
+ + +
+ Delete object store +
+ + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

initialize()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

objectStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

<abstract> objectStoreNames()

+ + +
+
+ + +
+ List storage names (e.g. tables for SQL, collections for MongoDB) +
+ + + + + + + + + +
+ + + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/RestStore.html b/docs/api/RestStore.html new file mode 100644 index 0000000..6995560 --- /dev/null +++ b/docs/api/RestStore.html @@ -0,0 +1,619 @@ + + + + + JSDoc: Class: RestStore + + + + + + + + + + +
+ +

Class: RestStore

+ + + + + +
+ +
+

+ RestStore +

+ +
+ +
+
+ + + + +
+

new RestStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + +

Methods

+ +
+ +
+

add()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

clear()

+ + +
+
+ + +
+ Delete all items +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

delete()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

get()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

initialize()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

put()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

query()

+ + +
+
+ + +
+ Execute RQL query +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/SqlBackend.html b/docs/api/SqlBackend.html new file mode 100644 index 0000000..cdd40f2 --- /dev/null +++ b/docs/api/SqlBackend.html @@ -0,0 +1,806 @@ + + + + + JSDoc: Class: SqlBackend + + + + + + + + + + +
+ +

Class: SqlBackend

+ + + + + +
+ +
+

+ SqlBackend +

+ +
+ +
+
+ + + + +
+

new SqlBackend()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + +

Methods

+ +
+ +
+

close()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

createObjectStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

deleteObjectStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

initialize()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

isClosed()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

objectStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

objectStoreNames()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

open()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

runSql()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

runSqlAll()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/SqlStore.html b/docs/api/SqlStore.html new file mode 100644 index 0000000..c07def5 --- /dev/null +++ b/docs/api/SqlStore.html @@ -0,0 +1,891 @@ + + + + + JSDoc: Class: SqlStore + + + + + + + + + + +
+ +

Class: SqlStore

+ + + + + +
+ +
+

+ SqlStore +

+ +
+ +
+
+ + + + +
+

new SqlStore()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+ + +

Extends

+ + + + + + + + + + + + + + + +

Methods

+ +
+ +
+

add()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

clear()

+ + +
+
+ + +
+ Delete all items +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

connection()

+ + +
+
+ + +
+ Get connection object +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

delete()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

escapeIdentifier()

+ + +
+
+ + +
+ Escape table or column name +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

get()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

parse()

+ + +
+
+ + +
+ Parse RQL query +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

put()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

query()

+ + +
+
+ + +
+ Execute RQL query +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

runSql()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + +
+

runSqlAll()

+ + +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/base.js.html b/docs/api/base.js.html new file mode 100644 index 0000000..af14550 --- /dev/null +++ b/docs/api/base.js.html @@ -0,0 +1,229 @@ + + + + + JSDoc: Source: base.js + + + + + + + + + + +
+ +

Source: base.js

+ + + + + +
+
+

+/** @module base */
+(function (factory) {
+    if (typeof module !== 'undefined' && typeof module.exports !== 'undefined' && typeof require !== 'undefined') {
+        // CommonJS
+        module.exports = factory(require('underscore'));
+    } else {
+        // running in browser
+        window.warehouse = window.warehouse || {};
+        window.warehouse.BaseBackend = factory(_);
+    }
+})(function(_) {
+
+/** @class BaseBackend */
+function BaseBackend() {
+    this.initialize.apply(this, arguments);
+}
+
+_.extend(BaseBackend.prototype,
+/** @lends BaseBackend# */
+{
+    /** Initialize the backend instance */
+    initialize: function(options) {
+        options = _.extend({}, options || {});
+        this.options = options;    
+    },
+
+    /** List storage names (e.g. tables for SQL, collections for MongoDB)
+        @abstract */
+    objectStoreNames: function() {
+
+    },
+
+    /** Get object store
+     * @abstract */
+    objectStore: function(name, options) {
+
+    },
+
+    /** Create object store
+        @abstract */
+    createObjectStore: function(name, options) {
+
+    },
+
+    /** Delete object store
+        @abstract */
+    deleteObjectStore: function(name) {
+
+    }
+});
+
+
+
+/** @class BaseStore */
+function BaseStore() {
+    this.initialize.apply(this, arguments);
+}
+
+_.extend(BaseStore.prototype,
+/** @lends BaseStore# */
+{
+    /** Initialize the backend instance
+        @constructs */
+    initialize: function(backend, name, options) {
+        options = _.extend({keyPath: 'id'}, options || {});
+        this.options = options;
+
+        this.backend = backend;
+        this.name = name;
+        this.keyPath = this.options.keyPath;
+    },
+
+    /** Get value (aka READ)
+        @abstract */
+    get: function(directives) {
+
+    },
+
+    /** Add value (aka CREATE, insert)
+        @abstract */
+    add: function(object, directives) {
+
+    },
+
+    /** Get value (aka UPDATE)
+        @abstract */
+    put: function(object, directives) {
+
+    },
+
+    /** Delete value (aka DELETE)
+        @abstract */
+    'delete': function(directives) {
+
+    },
+
+    /** Execute RQL query
+        @abstract */
+    query: function(query) {
+
+    },
+
+    /** Delete all items
+        @abstract */
+    clear: function() {
+
+    },
+
+    /** Extract key value from object
+        @private */
+    _getObjectKey: function(obj, key) {
+        if (typeof key === 'object') {
+            key = key.key;
+        }
+        return key || obj[this.keyPath];
+    }
+});
+
+// Taken from Backbone:
+
+  // Shared empty constructor function to aid in prototype-chain creation.
+  var ctor = function(){};
+
+  // Helper function to correctly set up the prototype chain, for subclasses.
+  // Similar to `goog.inherits`, but uses a hash of prototype properties and
+  // class properties to be extended.
+  var inherits = function(parent, protoProps, staticProps) {
+    var child;
+
+    // The constructor function for the new subclass is either defined by you
+    // (the "constructor" property in your `extend` definition), or defaulted
+    // by us to simply call the parent's constructor.
+    if (protoProps && protoProps.hasOwnProperty('constructor')) {
+      child = protoProps.constructor;
+    } else {
+      child = function(){ parent.apply(this, arguments); };
+    }
+
+    // Inherit class (static) properties from parent.
+    _.extend(child, parent);
+
+    // Set the prototype chain to inherit from `parent`, without calling
+    // `parent`'s constructor function.
+    ctor.prototype = parent.prototype;
+    child.prototype = new ctor();
+
+    // Add prototype properties (instance properties) to the subclass,
+    // if supplied.
+    if (protoProps) _.extend(child.prototype, protoProps);
+
+    // Add static properties to the constructor function, if supplied.
+    if (staticProps) _.extend(child, staticProps);
+
+    // Correctly set child's `prototype.constructor`.
+    child.prototype.constructor = child;
+
+    // Set a convenience property in case the parent's prototype is needed later.
+    child.__super__ = parent.prototype;
+
+    return child;
+  };
+
+  // The self-propagating extend function that Backbone classes use.
+  var extend = function (protoProps, classProps) {
+    var child = inherits(this, protoProps, classProps);
+    child.extend = this.extend;
+    return child;
+  };
+
+/** Class inheritance */
+BaseStore.extend = extend;
+
+/** Class inheritance */
+BaseBackend.extend = extend;
+BaseBackend.BaseStore = BaseStore;
+
+return BaseBackend;
+
+});
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/api/elasticsearch.js.html b/docs/api/elasticsearch.js.html new file mode 100644 index 0000000..cc1d6da --- /dev/null +++ b/docs/api/elasticsearch.js.html @@ -0,0 +1,232 @@ + + + + + JSDoc: Source: elasticsearch.js + + + + + + + + + + +
+ +

Source: elasticsearch.js

+ + + + + +
+
+

+/** @module elasticsearch */
+(function (factory) {
+    var ajax, Q;
+    if (typeof module !== 'undefined' && typeof module.exports !== 'undefined' && typeof require !== 'undefined') {
+        // CommonJS
+        Q = require('q');
+        ajax = function(method, url, data) {
+            var obj = {
+                method: method,
+                url: url,
+                json: data
+            };
+            return Q.nfcall(require('request'), obj)
+                    .then(function(response) {
+                        var body = response[1];
+                        return typeof body === 'string' ? JSON.parse(body) : body;
+                    });
+        };
+        module.exports = factory(ajax, require('underscore-data'), require('./base'), require('../rql/elasticsearch').rql2es);
+    } else {
+        // running in browser
+        Q = this.Q;
+        ajax = function(method, url, data) {
+            var obj = {
+                type: method,
+                url: url,
+                dataType: 'json'
+            };
+            if (data) {
+                obj.data = JSON.stringify(data);
+                //obj.contentType = 'application/json';
+            }
+            return Q.when($.ajax(obj));
+        };
+        window.warehouse = window.warehouse || {};
+        window.warehouse.ElasticSearchBackend = factory(ajax, _, warehouse.BaseBackend, warehouse.rql2es);
+    }
+})(function(ajax, _, BaseBackend, rql2es) {
+
+/** @class ElasticSearchBackend
+    @extends BaseBackend */
+var ElasticSearchBackend = BaseBackend.extend(
+/** @lends ElasticSearchBackend# */
+{
+    /** @method */
+    initialize: function(options) {
+        options = _.extend({url: '/'}, options || {});
+        options.url = options.url.replace(/\/?$/, '/');
+        this.options = options;
+
+        this.url = options.url;
+    },
+
+    // /** @method */
+    // objectStoreNames: function() {
+    //     return Q.defer()
+    //             .resolve(_.keys(this._stores));
+    // },
+
+    /** @method */
+    objectStore: function(name, options) {
+        var url = this.url + name;
+        return new ElasticSearchStore(this, name, url, options);
+    },
+
+    // /** @method */
+    // createObjectStore: function(name, options) {
+    //     return Q.defer()
+    //             .resolve(this.objectStore(name, options));
+    // },
+
+    // /** @method */
+    // deleteObjectStore: function(name) {
+    //     return Q.defer()
+    //             .resolve(delete this._stores[name]);
+    // }
+});
+
+
+
+/** @class ElasticSearchStore
+    @extends BaseStore */
+var ElasticSearchStore = BaseBackend.BaseStore.extend(
+/** @lends ElasticSearchStore# */
+{
+    /** @method */
+    initialize: function(backend, name, url, options) {
+        options = _.extend({keyPath: '_id'}, options || {});
+        BaseBackend.BaseStore.prototype.initialize.call(this, backend, name, options);
+
+        this._url = url;
+    },
+
+    /** @method */
+    get: function(directives) {
+        var key = this._getObjectKey({}, directives);
+
+        return ajax('GET', this._url +'/' + key)
+            .then(function(item) {
+                return item._source;
+            });
+    },
+
+    /** @method */
+    add: function(object, directives) {
+        return ElasticSearchStore.prototype.put.call(this, object, directives);
+    },
+
+    /** @method */
+    put: function(object, directives) {
+        object = _.clone(object);
+        var self = this;
+        var key = this._getObjectKey(object, directives);
+        // if (key) {
+        //     object[this.keyPath] = key;
+        // }
+        var url = this._url;
+        url += key ? '/' + key : '';
+
+        return ajax(key ? 'PUT' : 'POST', url, object)
+            .then(function(result) {
+                if (result.ok) {
+                    if (result && result._id) {
+                        key = result._id;
+
+                        // key to int coercion
+                        var intKey = parseInt(key, 10);
+                        if (!isNaN(intKey) && intKey.toString() === key) {
+                            key = intKey;
+                        }
+
+                        object[self.keyPath] = key;
+                    }
+                    return object;
+                } else {
+                    throw 'Not OK: ' + JSON.stringify(result);
+                }
+            });
+    },
+
+    /** @method */
+    'delete': function(directives) {
+        var key = this._getObjectKey({}, directives);
+
+        function handle(result) {
+                if (result && result.ok) {
+                    return result.found ? 1 : 0;
+                } else if (result && result.responseText) {
+                    result = JSON.parse(result.responseText);
+                    return result.found ? 1 : 0;
+                } else {
+                    throw 'Not OK: ' + JSON.stringify(result);
+                }
+            }
+
+        return ajax('DELETE', this._url + '/' + key)
+            .then(handle).fail(handle);            
+    },
+
+    /** Execute RQL query */
+    query: function(query) {
+        var q = rql2es(_.rql(query)),
+            mapFn = q.fields ?
+                          function(x) { return x.fields; } 
+                        : function(x) { return x._source; };
+        return ajax('POST', this._url + '/_search', q)
+            .then(function(result) {
+                return result.hits.hits.map(mapFn);
+            });
+    },
+
+    /** Delete all items */
+    clear: function() {
+        return ajax('DELETE', this._url + '/_query', {"match_all": {}});
+    }
+});
+
+ElasticSearchBackend.ElasticSearchStore = ElasticSearchStore;
+
+return ElasticSearchBackend;
+
+});
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/api/fs.js.html b/docs/api/fs.js.html new file mode 100644 index 0000000..24b8211 --- /dev/null +++ b/docs/api/fs.js.html @@ -0,0 +1,203 @@ + + + + + JSDoc: Source: fs.js + + + + + + + + + + +
+ +

Source: fs.js

+ + + + + +
+
+
var fs = require('fs'),
+    path = require('path'),
+    Q = require('q'),
+    _ = require('underscore-data'),
+    BaseBackend = require('./base');
+
+function resolvedPromise(val) {
+    var d = Q.defer();
+    d.resolve(val);
+    return d.promise;
+}
+
+/** @class FsBackend
+    @extends BaseBackend */
+var FsBackend = BaseBackend.extend(
+/** @lends FsBackend# */
+{
+    /** @method */
+    initialize: function(options) {
+        BaseBackend.prototype.initialize.call(this, options);
+    },
+
+    /** @method */
+    objectStoreNames: function() {
+        return Q.ninvoke(fs, 'readdir', this.options.path);
+    },
+
+    /** @method */
+    objectStore: function(name, options) {
+        name = path.basename(name);
+        return new FsStore(this, name, options);
+    },
+
+    /** @method */
+    createObjectStore: function(name, options) {
+        var d = Q.defer();
+        name = path.basename(name);
+        fs.mkdir(path.join(this.options.path, name), function() {
+            d.resolve(this.objectStore(name, options));
+        }.bind(this));
+        return d.promise;
+    },
+
+    /** @method */
+    deleteObjectStore: function(name) {
+        name = path.basename(name);
+        this.objectStore(name).clear().then(function() {
+            return Q.ninvoke(fs, 'rmdir', path.join(this.options.path, name));
+        });
+    },
+    /** Encode object into string, by default uses JSON.stringify
+        Override to use different serialization
+        @method */
+    encode: JSON.stringify,
+    /** Decode string into object, by default uses JSON.parse
+        Override to use different serialization
+        @method */
+    decode: JSON.parse
+});
+
+
+
+/** @class FsStore
+    @extends BaseStore */
+var FsStore = BaseBackend.BaseStore.extend(
+/** @lends FsStore# */
+{
+    /** @method */
+    initialize: function(backend, name, options) {
+        BaseBackend.BaseStore.prototype.initialize.call(this, backend, name, options);
+    },
+
+    /** @method */
+    get: function(directives) {
+        var key = this._getObjectKey({}, directives);
+        return Q.ninvoke(fs, 'readFile', this.filename(key), 'utf-8')
+            .then(function(x) {
+                return this.backend.decode(x);
+            }.bind(this));
+    },
+
+    /** @method */
+    add: function(object, directives) {
+        var key = this._getObjectKey(object, directives);
+
+        return Q.ninvoke(fs, 'writeFile', this.filename(key), this.backend.encode(object), {flag: 'wx'}).then(function() {
+            return object;
+        });
+    },
+
+    /** @method */
+    put: function(object, directives) {
+        var key = this._getObjectKey(object, directives);
+
+        return Q.ninvoke(fs, 'writeFile', this.filename(key), this.backend.encode(object), {flag: 'w'}).then(function() {
+            return object;
+        });
+    },
+
+    /** @method */
+    'delete': function(directives) {
+        var key = this._getObjectKey({}, directives),
+            d = Q.defer();
+
+        Q.ninvoke(fs, 'unlink', this.filename(key))
+            .then(function() {
+                d.resolve(1);
+            })
+            .fail(function() {
+                d.resolve(0);
+            });
+
+        return d.promise;
+    },
+
+    /** Execute RQL query */
+    query: function(query) {
+        var self = this;
+        return Q.ninvoke(fs, 'readdir', path.join(this.backend.options.path, this.name))
+            .then(function(files) {
+                return Q.all(files.map(function(f) {
+                    return self.get(f);
+                }));
+            })
+            .then(function(vals) {
+                return _.query(vals, query);
+            });
+    },
+
+    /** Delete all items */
+    clear: function() {
+        var self = this;
+        return Q.ninvoke(fs, 'readdir', path.join(this.backend.options.path, this.name))
+            .then(function(files) {
+                return Q.all(files.map(function(f) {
+                    return self.delete(f);
+                }));
+            })
+            .then(function() {
+                return true;
+            });
+    },
+
+    /** Get absolute filename for given key */
+    filename: function(file) {
+        return path.join(this.backend.options.path, this.name, ''+path.basename(file));
+    } 
+});
+
+/** @module fs */
+
+FsBackend.FsStore = FsStore;
+module.exports = FsBackend;
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/api/index.html b/docs/api/index.html new file mode 100644 index 0000000..ed1dd2b --- /dev/null +++ b/docs/api/index.html @@ -0,0 +1,63 @@ + + + + + JSDoc: Index + + + + + + + + + + +
+ +

Index

+ + + + + + + +

+ + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/local.js.html b/docs/api/local.js.html new file mode 100644 index 0000000..ebdf5f5 --- /dev/null +++ b/docs/api/local.js.html @@ -0,0 +1,170 @@ + + + + + JSDoc: Source: local.js + + + + + + + + + + +
+ +

Source: local.js

+ + + + + +
+
+

+/** @module local */
+(function (factory) {
+    // if (typeof module !== 'undefined' && typeof module.exports !== 'undefined' && typeof require !== 'undefined') {
+    //     // CommonJS
+    //     module.exports = factory(require('q'), require('underscore-data'), require('..').extend);
+    // } else {
+        // running in browser
+        window.warehouse = window.warehouse || {};
+        window.warehouse.LocalBackend = factory(Q, _, warehouse.BaseBackend);
+    // }
+})(function(Q, _, BaseBackend) {
+
+function resolvedPromise(val) {
+    var d = Q.defer();
+    d.resolve(val);
+    return d.promise;
+}
+
+/** @class LocalBackend
+    @extends BaseBackend */
+var LocalBackend = BaseBackend.extend(
+/** @lends LocalBackend# */
+{
+    /** @method */
+    initialize: function(options) {
+        BaseBackend.prototype.initialize.call(this, options);
+
+        if (typeof Storage === "undefined") {
+          throw "No web storage support!";
+        }        
+    },
+
+    /** @method */
+    objectStoreNames: function() {
+        return ['local', 'session'];
+    },
+
+    /** @method */
+    objectStore: function(name, options) {
+        return new LocalStore(this, name, options);
+    },
+
+    /** @method */
+    createObjectStore: function(name, options) {
+        return resolvedPromise(this.objectStore(name, options));
+    },
+
+    /** @method */
+    deleteObjectStore: function(name) {
+        return resolvedPromise(this.objectStore(name).clear());
+    }
+});
+
+
+
+/** @class LocalStore
+    @extends BaseStore */
+var LocalStore = BaseBackend.BaseStore.extend(
+/** @lends LocalStore# */
+{
+    /** @method */
+    initialize: function(backend, name, options) {
+        BaseBackend.BaseStore.prototype.initialize.call(this, backend, name, options);
+
+        this._store = name === 'session' ? sessionStorage : localStorage;
+    },
+
+    /** @method */
+    get: function(directives) {
+        var key = this._getObjectKey({}, directives);
+
+        return resolvedPromise(JSON.parse(this._store.getItem(key)));
+    },
+
+    /** @method */
+    add: function(object, directives) {
+        return this.put(object, directives);
+    },
+
+    /** @method */
+    put: function(object, directives) {
+        object = _.clone(object);
+        var key = this._getObjectKey(object, directives);
+
+        this._store.setItem(key, JSON.stringify(object));
+
+        return resolvedPromise(object);
+    },
+
+    /** @method */
+    'delete': function(directives) {
+        var key = this._getObjectKey({}, directives);
+
+        val = this._store.getItem(key) ? 1 : 0;
+        this._store.removeItem(key);
+
+        return resolvedPromise(val);
+    },
+
+    /** Execute RQL query */
+    query: function(query) {
+        var items = [];
+        for (var i = 0; i < this._store.length; i++) {
+            items.push(JSON.parse(this._store.getItem(this._store.key(i))));
+        }
+        return resolvedPromise(_.query(items, query));
+    },
+
+    /** Delete all items */
+    clear: function() {
+        this._store.clear();
+        return resolvedPromise(true);
+    }
+});
+
+LocalBackend.LocalStore = LocalStore;
+
+return LocalBackend;
+
+});
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/api/memory.js.html b/docs/api/memory.js.html new file mode 100644 index 0000000..4608998 --- /dev/null +++ b/docs/api/memory.js.html @@ -0,0 +1,197 @@ + + + + + JSDoc: Source: memory.js + + + + + + + + + + +
+ +

Source: memory.js

+ + + + + +
+
+

+/** @module memory */
+(function (factory) {
+    if (typeof module !== 'undefined' && typeof module.exports !== 'undefined' && typeof require !== 'undefined') {
+        // CommonJS
+        module.exports = factory(require('q'), require('underscore-data'), require('./base'));
+    } else {
+        // running in browser
+        window.warehouse = window.warehouse || {};
+        window.warehouse.MemoryBackend = factory(Q, _, warehouse.BaseBackend);
+    }
+})(function(Q, _, BaseBackend) {
+
+function resolvedPromise(val) {
+    var d = Q.defer();
+    d.resolve(val);
+    return d.promise;
+}
+
+/** @class MemoryBackend
+    @extends BaseBackend */
+var MemoryBackend = BaseBackend.extend(
+/** @lends MemoryBackend# */
+{
+    /** @method */
+    initialize: function(options) {
+        BaseBackend.prototype.initialize.call(this, options);
+
+        this._stores = {};
+    },
+
+    /** @method */
+    objectStoreNames: function() {
+        return resolvedPromise(_.keys(this._stores));
+    },
+
+    /** @method */
+    objectStore: function(name, options) {
+        if (!this._stores[name]) {
+            this._stores[name] = [];
+        }
+        return new MemoryStore(this, name, this._stores[name], options);
+    },
+
+    /** @method */
+    createObjectStore: function(name, options) {
+        return resolvedPromise(this.objectStore(name, options));
+    },
+
+    /** @method */
+    deleteObjectStore: function(name) {
+        return resolvedPromise(delete this._stores[name]);
+    }
+});
+
+
+
+/** @class MemoryStore
+    @extends BaseStore */
+var MemoryStore = BaseBackend.BaseStore.extend(
+/** @lends MemoryStore# */
+{
+    /** @method */
+    initialize: function(backend, name, store, options) {
+        BaseBackend.BaseStore.prototype.initialize.call(this, backend, name, options);
+
+        this.fromJSON(options.json);
+    },
+
+    /** @method */
+    get: function(directives) {
+        var key = this._getObjectKey({}, directives);
+
+        return resolvedPromise(this._store[key]);
+    },
+
+    /** @method */
+    add: function(object, directives) {
+        object = _.clone(object);
+        var key = this._getObjectKey(object, directives);
+
+        this._store[key] = object;
+
+        return resolvedPromise(object);
+    },
+
+    /** @method */
+    put: function(object, directives) {
+        object = _.clone(object);
+        var key = this._getObjectKey(object, directives);
+
+        this._store[key] = object;
+
+        return resolvedPromise(object);
+    },
+
+    /** @method */
+    'delete': function(directives) {
+        var key = this._getObjectKey({}, directives);
+
+        var val = this._store[key] && delete (this._store)[key];
+        val = val ? 1 : 0;
+
+        return resolvedPromise(val);
+    },
+
+    /** Execute RQL query */
+    query: function(query) {
+        return resolvedPromise(_.query(_.values(this._store), query));
+    },
+
+    /** Delete all items */
+    clear: function() {
+        this._store = {};
+        return resolvedPromise(true);
+    },
+
+    /** Sets data to be used */
+    fromJSON: function(data) {
+        var ret = {};
+        if (typeof data === 'string') {
+            try {
+                this.fromJSON(JSON.parse(data));
+                return;
+            } catch(e) {
+            }
+        } else if (typeof data === 'object') {
+            if (data.constructor && data.constructor.name === 'Array') {
+                for (var i = 0; i < data.length; i++) {
+                    ret[this._getObjectKey(data[i]) || i] = data[i];
+                }
+            } else {
+                ret = data;
+            }
+        }
+        this._store = ret;
+    },
+
+    /** Returns copy of all data */
+    toJSON: function() {
+        return _.clone(this._store);
+    }
+});
+
+MemoryBackend.MemoryStore = MemoryStore;
+return MemoryBackend;
+
+});
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/api/module-base.html b/docs/api/module-base.html new file mode 100644 index 0000000..20138cb --- /dev/null +++ b/docs/api/module-base.html @@ -0,0 +1,120 @@ + + + + + JSDoc: Module: base + + + + + + + + + + +
+ +

Module: base

+ + + + + +
+ +
+

+ base +

+ +
+ +
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/module-elasticsearch.html b/docs/api/module-elasticsearch.html new file mode 100644 index 0000000..b25dfde --- /dev/null +++ b/docs/api/module-elasticsearch.html @@ -0,0 +1,120 @@ + + + + + JSDoc: Module: elasticsearch + + + + + + + + + + +
+ +

Module: elasticsearch

+ + + + + +
+ +
+

+ elasticsearch +

+ +
+ +
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/module-fs.html b/docs/api/module-fs.html new file mode 100644 index 0000000..af9953b --- /dev/null +++ b/docs/api/module-fs.html @@ -0,0 +1,120 @@ + + + + + JSDoc: Module: fs + + + + + + + + + + +
+ +

Module: fs

+ + + + + +
+ +
+

+ fs +

+ +
+ +
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/module-local.html b/docs/api/module-local.html new file mode 100644 index 0000000..e11e61e --- /dev/null +++ b/docs/api/module-local.html @@ -0,0 +1,120 @@ + + + + + JSDoc: Module: local + + + + + + + + + + +
+ +

Module: local

+ + + + + +
+ +
+

+ local +

+ +
+ +
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/module-memory.html b/docs/api/module-memory.html new file mode 100644 index 0000000..104fa58 --- /dev/null +++ b/docs/api/module-memory.html @@ -0,0 +1,120 @@ + + + + + JSDoc: Module: memory + + + + + + + + + + +
+ +

Module: memory

+ + + + + +
+ +
+

+ memory +

+ +
+ +
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/module-mongodb.html b/docs/api/module-mongodb.html new file mode 100644 index 0000000..be7ed0d --- /dev/null +++ b/docs/api/module-mongodb.html @@ -0,0 +1,120 @@ + + + + + JSDoc: Module: mongodb + + + + + + + + + + +
+ +

Module: mongodb

+ + + + + +
+ +
+

+ mongodb +

+ +
+ +
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/module-nedb.html b/docs/api/module-nedb.html new file mode 100644 index 0000000..93b732e --- /dev/null +++ b/docs/api/module-nedb.html @@ -0,0 +1,120 @@ + + + + + JSDoc: Module: nedb + + + + + + + + + + +
+ +

Module: nedb

+ + + + + +
+ +
+

+ nedb +

+ +
+ +
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/module-rest.html b/docs/api/module-rest.html new file mode 100644 index 0000000..135bee7 --- /dev/null +++ b/docs/api/module-rest.html @@ -0,0 +1,120 @@ + + + + + JSDoc: Module: rest + + + + + + + + + + +
+ +

Module: rest

+ + + + + +
+ +
+

+ rest +

+ +
+ +
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/module-sql.html b/docs/api/module-sql.html new file mode 100644 index 0000000..989a16a --- /dev/null +++ b/docs/api/module-sql.html @@ -0,0 +1,120 @@ + + + + + JSDoc: Module: sql + + + + + + + + + + +
+ +

Module: sql

+ + + + + +
+ +
+

+ sql +

+ +
+ +
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/api/mongodb.js.html b/docs/api/mongodb.js.html new file mode 100644 index 0000000..77731f2 --- /dev/null +++ b/docs/api/mongodb.js.html @@ -0,0 +1,265 @@ + + + + + JSDoc: Source: mongodb.js + + + + + + + + + + +
+ +

Source: mongodb.js

+ + + + + +
+
+
var Db = require('mongodb').Db,
+    Connection = require('mongodb').Connection,
+    Server = require('mongodb').Server,
+    Q = require('q'),
+    _ = require('underscore-data'),
+    BaseBackend = require('./base');
+
+
+
+
+/** @class MongoBackend
+    @extends BaseBackend */
+var MongoBackend = BaseBackend.extend(
+/** @lends MongoBackend# */
+{
+    /** @method */
+    initialize: function(options) {
+        options = _.extend({}, MongoBackend.defaults, options || {});
+        this.options = options;
+
+        this._db = new Db(options.database, new Server(options.host, options.port,  {auto_reconnect: true})/*, {native_parser:true}*/);
+
+        this._opened = null;
+    },
+
+    /** @method */
+    objectStoreNames: function() {
+        return this.open().then(function(db) {
+            return Q.ninvoke(db, 'collectionNames');
+        });
+    },
+
+    /** @method */
+    objectStore: function(name, options) {
+        return new MongoStore(this, name, options);
+    },
+
+    /** @method */
+    createObjectStore: function(name, options) {
+        return this.open().then(function(db) {
+            return Q.ninvoke(db, 'collection', name).then(function() {
+                return new MongoStore(this, name, options);
+            });
+        });
+    },
+
+    /** @method */
+    deleteObjectStore: function(name) {
+        return this.open().then(function(db) {
+            return Q.ninvoke(db, 'dropCollection', name);
+        });
+    },
+
+    /** @method */
+    open: function() {
+        var self = this;
+        if (!this._opened) {
+            this._opened = Q.ninvoke(this._db, 'open')
+                .then(function (db) {
+                    if (self.options.username) {
+                        return Q.ninvoke(db, 'authenticate', self.options.username, self.options.password)
+                                .then(function() {
+                                    return db;
+                                });
+                    } else {
+                        return db;
+                    }
+                });
+        }
+        return this._opened;
+    },
+
+    /** @method */
+    close: function() {
+        if (this._opened) {
+            this._opened = false;
+            return Q.ninvoke(this._db, 'close');
+        }
+    },
+
+    /** @method */
+    isClosed: function() {
+        return Q.defer()
+                .resolve(!!this._opened);
+    }
+});
+
+MongoBackend.defaults = {
+    host: 'localhost',
+    port: 27017,
+    database: 'default'
+};
+
+/** @class MongoStore
+    @extends BaseStore */
+var MongoStore = BaseBackend.BaseStore.extend(
+/** @lends MongoStore# */
+{
+    /** @method */
+    initialize: function(backend, name, options) {
+        options = _.extend({keyPath: '_id'}, options || {});
+        BaseBackend.BaseStore.prototype.initialize.call(this, backend, name, options);
+
+        this._collection = null;
+    },
+
+    /** @method */
+    get: function(directives) {
+        var search = {};
+        search[this.keyPath] = this._getObjectKey({}, directives);
+        return this.collection().then(function(collection) {
+            return Q.ninvoke(collection, 'findOne', search);
+        });
+    },
+
+    /** @method */
+    add: function(object, directives) {
+        //var key = this._getObjectKey(object, directives);
+
+        return this.collection().then(function(collection) {
+            return Q.ninvoke(collection, 'insert', object, {safe:true})
+                    .then(function(result) {
+                        return result[0] || object;
+                    });
+        });
+    },
+
+    /** @method */
+    put: function(object, directives) {
+        var key = this._getObjectKey(object, directives),
+            selector = {};
+        selector[this.keyPath] = key;
+        return this.collection().then(function(collection) {
+            return Q.ninvoke(collection, 'update', selector, object, {safe:true})
+                    .then(function(result) {
+                        return object;
+                    });
+        });
+    },
+
+    /** @method */
+    'delete': function(directives) {
+        var search = {};
+        search[this.keyPath] = this._getObjectKey({}, directives);
+        return this.collection().then(function(collection) {
+            return Q.ninvoke(collection, 'remove', search, {safe:true, single: true});
+        });
+    },
+
+    /** Execute RQL query */
+    query: function(query) {
+        var meta = {},
+            search = {};
+        if (query && !_.isEmpty(query)) {
+            var x = this.parse(query);
+            search = x.search;
+            meta = x.meta;
+        }
+
+        return this.collection().then(function(collection) {
+            return Q.ninvoke(collection, 'find', search||{}, meta||{})
+                    .then(function(cursor) {
+                        return Q.ninvoke(cursor, 'toArray');
+                    });
+        });
+    },
+
+    /** Get native DB object */
+    db: function() {
+        return this.backend.open();
+    },
+
+    /** Get Collection object */
+    collection: function() {
+        if (!this._collection) {
+            var self = this;
+            this._collection = this.db().then(function(db) {
+                return Q.ninvoke(db, 'collection', self.name);
+            });
+        }
+        return this._collection;
+    },
+
+    /** Delete all items */
+    clear: function() {
+        return this.collection().then(function(collection) {
+            return Q.ninvoke(collection, 'remove', {}, {safe: true});
+        });
+    },
+
+    /** Parse RQL query */
+    parse: function(query) {
+        return _.rql(query).toMongo();
+    },
+
+    /* @method */
+    _getObjectKey: function(obj, key) {
+        if (typeof key === 'object') {
+            key = key.key;
+        }
+
+        key =  key || obj[this.keyPath];
+
+        var intKey = parseInt(key, 10);
+        if (!isNaN(intKey) && intKey.toString() === key) {
+            key = intKey;
+        }
+
+        return key;
+    }
+});
+
+/** @module mongodb */
+
+MongoBackend.MongoStore = MongoStore;
+module.exports = MongoBackend;
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/api/nedb.js.html b/docs/api/nedb.js.html new file mode 100644 index 0000000..c97b743 --- /dev/null +++ b/docs/api/nedb.js.html @@ -0,0 +1,199 @@ + + + + + JSDoc: Source: nedb.js + + + + + + + + + + +
+ +

Source: nedb.js

+ + + + + +
+
+
var Datastore = require('nedb'),
+    Q = require('q'),
+    _ = require('underscore-data'),
+    BaseBackend = require('./base');
+
+
+
+
+/** @class NeBackend
+    @extends BaseBackend */
+var NeBackend = BaseBackend.extend(
+/** @lends NeBackend# */
+{
+    /** @method */
+    initialize: function(options) {
+        options = options || {};
+        this.options = options;
+    },
+
+    /** @method */
+    objectStore: function(name, options) {
+        return new NeStore(this, name, options);
+    }
+
+});
+
+/** @class NeStore
+    @extends BaseStore */
+var NeStore = BaseBackend.BaseStore.extend(
+/** @lends NeStore# */
+{
+    /** @method */
+    initialize: function(backend, name, options) {
+        options = _.extend({keyPath: 'id'}, options || {});
+        BaseBackend.BaseStore.prototype.initialize.call(this, backend, name, options);
+        var db = this._db = new Datastore(options);
+
+        this._collection = Q.ninvoke(db, 'loadDatabase').then(function() {
+            return db;
+        });
+    },
+
+    /** @method */
+    get: function(directives) {
+        var search = {};
+        search[this.keyPath] = this._getObjectKey({}, directives);
+        return this.collection().then(function(collection) {
+            return Q.ninvoke(collection, 'findOne', search);
+        });
+    },
+
+    /** @method */
+    add: function(object, directives) {
+        //var key = this._getObjectKey(object, directives);
+
+        return this.collection().then(function(collection) {
+            return Q.ninvoke(collection, 'insert', object)
+                    .then(function(result) {
+                        return result || object;
+                    });
+        });
+    },
+
+    /** @method */
+    put: function(object, directives) {
+        var key = this._getObjectKey(object, directives),
+            selector = {};
+        selector[this.keyPath] = key;
+        return this.collection().then(function(collection) {
+            return Q.ninvoke(collection, 'update', selector, object, {})
+                    .then(function(result) {
+                        return object;
+                    });
+        });
+    },
+
+    /** @method */
+    'delete': function(directives) {
+        var search = {};
+        search[this.keyPath] = this._getObjectKey({}, directives);
+        return this.collection().then(function(collection) {
+            return Q.ninvoke(collection, 'remove', search);
+        });
+    },
+
+    /** Execute RQL query */
+    query: function(query) {
+        var meta = {},
+            search = {};
+        if (query && !_.isEmpty(query)) {
+            var x = this.parse(query);
+            search = x.search;
+            meta = x.meta;
+        }
+
+        return this.collection().then(function(collection) {
+            return Q.ninvoke(collection, 'find', search||{}/*, meta||{}*/)
+                    .then(function(result) {
+                        // run through _.query to enable sorting which is not yet implemented in NeDB
+                        // see https://github.com/louischatriot/nedb/issues/64
+                        return _.query(result, query);
+                    });
+        });
+    },
+
+    /** Get native DB object */
+    db: function() {
+        return this.backend.open();
+    },
+
+    /** Get Collection object */
+    collection: function() {
+        return this._collection;
+    },
+
+    /** Delete all items */
+    clear: function() {
+        return this.collection().then(function(collection) {
+            return Q.ninvoke(collection, 'remove', {}, {safe: true});
+        });
+    },
+
+    /**
+     * Parse RQL query
+     * @function
+     */
+    parse: function(query) {
+        return _.rql(query).toMongo();
+    },
+
+    _getObjectKey: function(obj, key) {
+        if (typeof key === 'object') {
+            key = key.key;
+        }
+
+        key =  key || obj[this.keyPath];
+
+        var intKey = parseInt(key, 10);
+        if (!isNaN(intKey) && intKey.toString() === key) {
+            key = intKey;
+        }
+
+        return key;
+    }
+});
+
+/** @module nedb */
+
+NeBackend.NeStore = NeStore;
+module.exports = NeBackend;
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/api/rest.js.html b/docs/api/rest.js.html new file mode 100644 index 0000000..52029bc --- /dev/null +++ b/docs/api/rest.js.html @@ -0,0 +1,194 @@ + + + + + JSDoc: Source: rest.js + + + + + + + + + + +
+ +

Source: rest.js

+ + + + + +
+
+

+/** @module rest */
+(function (factory) {
+    var ajax, Q;
+    if (typeof module !== 'undefined' && typeof module.exports !== 'undefined' && typeof require !== 'undefined') {
+        // CommonJS
+        Q = require('q');
+        ajax = function(method, url, data) {
+            var obj = {
+                method: method,
+                url: url,
+                json: data
+            };
+            return Q.nfcall(require('request'), obj)
+                    .then(function(response) {
+                        var body = response[1];
+                        return typeof body === 'string' ? JSON.parse(body) : body;
+                    });
+        };
+        module.exports = factory(ajax, require('underscore-data'), require('./base'));
+    } else {
+        // running in browser
+        Q = this.Q;
+        ajax = function(method, url, data) {
+            var obj = {
+                type: method,
+                url: url,
+                dataType: 'json'
+            };
+            if (data) {
+                obj.data = JSON.stringify(data);
+                obj.contentType = 'application/json';
+            }
+            return Q.when($.ajax(obj));
+        };
+        window.warehouse = window.warehouse || {};
+        window.warehouse.RestBackend = factory(ajax, _, warehouse.BaseBackend);
+    }
+})(function(ajax, _, BaseBackend) {
+
+/** @class RestBackend
+    @extends BaseBackend */
+var RestBackend = BaseBackend.extend(
+/** @lends RestBackend# */
+{
+    /** @method */
+    initialize: function(options) {
+        options = _.extend({url: '/'}, options || {});
+        options.url = options.url.replace(/\/?$/, '/');
+        this.options = options;
+
+        this.url = options.url;
+    },
+
+    // /** @method */
+    // objectStoreNames: function() {
+    //     return Q.defer()
+    //             .resolve(_.keys(this._stores));
+    // },
+
+    /** @method */
+    objectStore: function(name, options) {
+        var url = this.url + name;
+        return new RestStore(this, name, url, options);
+    },
+
+    // /** @method */
+    // createObjectStore: function(name, options) {
+    //     return Q.defer()
+    //             .resolve(this.objectStore(name, options));
+    // },
+
+    // /** @method */
+    // deleteObjectStore: function(name) {
+    //     return Q.defer()
+    //             .resolve(delete this._stores[name]);
+    // }
+});
+
+
+
+/** @class RestStore
+    @extends BaseStore */
+var RestStore = BaseBackend.BaseStore.extend(
+/** @lends RestStore# */
+{
+    /** @method */
+    initialize: function(backend, name, url, options) {
+        BaseBackend.BaseStore.prototype.initialize.call(this, backend, name, options);
+
+        this._url = url;
+    },
+
+    /** @method */
+    get: function(directives) {
+        var key = this._getObjectKey({}, directives);
+
+        return ajax('GET', this._url+'/' + key);
+    },
+
+    /** @method */
+    add: function(object, directives) {
+        object = _.clone(object);
+        // var key = this._getObjectKey(object, directives);
+        // if (key) {
+        //     object[this.keyPath] = key;
+        // }
+
+        return ajax('POST', this._url, object);
+    },
+
+    /** @method */
+    put: function(object, directives) {
+        object = _.clone(object);
+        var key = this._getObjectKey(object, directives);
+        // if (key) {
+        //     object[this.keyPath] = key;
+        // }
+
+        return ajax('PUT', this._url + '/' + key, object);
+    },
+
+    /** @method */
+    'delete': function(directives) {
+        var key = this._getObjectKey({}, directives);
+
+        return ajax('DELETE', this._url + '/' + key);  
+    },
+
+    /** Execute RQL query */
+    query: function(query) {
+        return ajax('GET', this._url + (query ? '?' + _.rql(query).toString() : ''));
+    },
+
+    /** Delete all items */
+    clear: function() {
+        return ajax('DELETE', this._url);
+    }
+});
+
+RestBackend.RestStore = RestStore;
+
+return RestBackend;
+
+});
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/api/scripts/linenumber.js b/docs/api/scripts/linenumber.js new file mode 100644 index 0000000..613865d --- /dev/null +++ b/docs/api/scripts/linenumber.js @@ -0,0 +1,17 @@ +(function() { + var counter = 0; + var numbered; + var source = document.getElementsByClassName('prettyprint source'); + + if (source && source[0]) { + source = source[0].getElementsByTagName('code')[0]; + + numbered = source.innerHTML.split('\n'); + numbered = numbered.map(function(item) { + counter++; + return '' + item; + }); + + source.innerHTML = numbered.join('\n'); + } +})(); diff --git a/docs/api/scripts/prettify/Apache-License-2.0.txt b/docs/api/scripts/prettify/Apache-License-2.0.txt new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/docs/api/scripts/prettify/Apache-License-2.0.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/docs/api/scripts/prettify/lang-css.js b/docs/api/scripts/prettify/lang-css.js new file mode 100644 index 0000000..041e1f5 --- /dev/null +++ b/docs/api/scripts/prettify/lang-css.js @@ -0,0 +1,2 @@ +PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com", +/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); diff --git a/docs/api/scripts/prettify/prettify.js b/docs/api/scripts/prettify/prettify.js new file mode 100644 index 0000000..eef5ad7 --- /dev/null +++ b/docs/api/scripts/prettify/prettify.js @@ -0,0 +1,28 @@ +var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; +(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a= +[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m), +l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, +q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/, +q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g, +"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a), +a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e} +for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], +"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"], +H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], +J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+ +I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]), +["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css", +/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}), +["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes", +hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p=0){var k=k.match(g),f,b;if(b= +!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p + + + + JSDoc: Source: sql.js + + + + + + + + + + +
+ +

Source: sql.js

+ + + + + +
+
+
var persist = require('persist'),
+    Q = require('q'),
+    _ = require('underscore-data'),
+    extend = require('..').extend,
+    util = require('util'),
+    BaseBackend = require('./base'),
+    rql = require('../rql/sql');
+
+/** @class SqlBackend 
+    @extends BaseBackend */
+var SqlBackend = BaseBackend.extend(
+/** @lends SqlBackend# */
+{
+    /** @method */
+    initialize: function(options) {
+        options = _.extend({driver: 'mysql'}, SqlBackend.defaults, options || {});
+        this.options = options;
+
+        this._opened = null;
+    },
+
+    /** @method */
+    objectStoreNames: function() {
+        var sql = (this.options.driver === 'sqlite3') ? 
+              "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;"
+            : "SHOW TABLES;";
+        return this.runSqlAll(sql);
+    },
+
+    /** @method */
+    objectStore: function(name, options) {
+        return new SqlStore(this, name, options);
+    },
+
+    /** @method */
+    createObjectStore: function(name, options) {
+        throw 'Not implemented - please use CREATE TABLE query';
+    },
+
+    /** @method */
+    deleteObjectStore: function(name) {
+        return this.runSql('DROP TABLE ' + SqlStore.prototype.escapeIdentifier(name));
+    },
+
+    /** @method */
+    open: function() {
+        if (!this._opened) {
+            this._opened = Q.ninvoke(persist, 'connect', this.options);
+        }
+        return this._opened;
+    },
+
+    /** @method */
+    close: function() {
+        throw 'Not implemented!';
+    },
+
+    /** @method */
+    isClosed: function() {
+        return Q.defer()
+                .resolve(!!this._opened);
+    },
+
+    /** @method */
+    runSql: function(sql, values) {
+        return this.open().then(function(connection) {
+            return Q.ninvoke(connection, 'runSql', sql, values||[]);
+        });
+    },
+
+    /** @method */
+    runSqlAll: function(sql, values) {
+        return this.open().then(function(connection) {
+            return Q.ninvoke(connection, 'runSqlAll', sql, values||[]);
+        });
+    },
+});
+
+SqlBackend.defaults = {
+    host: 'localhost',
+    port: 3306,
+    database: 'default'
+};
+
+
+/** @class SqlStore
+    @extends BaseStore */
+var SqlStore = BaseBackend.BaseStore.extend(
+/** @lends SqlStore# */
+{
+    /** @method */
+    get: function(directives) {
+        var key = this._getObjectKey({}, directives),
+            sql = util.format('SELECT * FROM %s WHERE %s = ?;',
+                              this.escapeIdentifier(this.name),
+                              this.escapeIdentifier(this.keyPath));
+        
+        return this.runSqlAll(sql, [key])
+            .then(function(result) {
+                return result[0] || {};
+            });
+    },
+
+    /** @method */
+    add: function(object, directives) {
+        var args = [],
+            placeholders = [],
+            self = this;
+
+        for (var k in object) {
+            args.push(object[k]);
+            placeholders.push(this.escapeIdentifier(k));
+        }
+
+        var sql = util.format('INSERT INTO %s (%s) VALUES (%s);',
+                              this.escapeIdentifier(this.name),
+                              placeholders.join(','),
+                              args.map(function() {return '?';}).join(','));
+
+        return this.runSql(sql, args)
+            .then(function(result) {
+                // handle autoincrement
+                if (result.insertId) {
+                    // MySQL
+                    object[self.keyPath] = result.insertId;
+                } else if (result.lastId) {
+                    // Sqlite
+                    object[self.keyPath] = result.lastId;
+                }
+                return object;
+            });
+    },
+
+    /** @method */
+    put: function(object, directives) {
+        var key = this._getObjectKey(object, directives),
+            args = [],
+            placeholders = [];
+
+        for (var k in object) {
+            args.push(object[k]);
+            placeholders.push(this.escapeIdentifier(k)+'=?');
+        }
+
+        args.push(key);
+
+        var sql = util.format('UPDATE %s SET %s WHERE %s = ?;',
+                              this.escapeIdentifier(this.name),
+                              placeholders.join(','),
+                              this.escapeIdentifier(this.keyPath));
+
+        return this.runSql(sql, args)
+            .then(function(result) {
+                return object;
+            });
+    },
+
+    /** @method */
+    'delete': function(directives) {
+        var key = this._getObjectKey({}, directives),
+            sql = util.format('DELETE FROM %s WHERE %s = ?;',
+                              this.escapeIdentifier(this.name),
+                              this.escapeIdentifier(this.keyPath));
+
+        return this.runSql(sql, [key])
+            .then(function(result) {
+                // return number of affected rows
+                var ret = 0;
+                if ('affectedRows' in result) {
+                    // MySQL
+                    ret = result.affectedRows;
+                } else if ('changes' in result) {
+                    // Sqlite
+                    ret = result.changes;
+                }
+                return ret;
+            });
+    },
+
+    /** Execute RQL query */
+    query: function(query) {
+        var sql = this.parse(query);
+
+        return this.runSqlAll(sql, [])
+            .then(function(result) {
+                if (result[0] && result[0][0]) {
+                  // sqlite
+                  result = result[0];
+                }
+                return result || [];
+            });
+    },
+
+    /** Get connection object */
+    connection: function() {
+        return this.backend.open();
+    },
+
+    /** Delete all items */
+    clear: function() {
+        var sql = util.format('DELETE FROM %s;', this.escapeIdentifier(this.name));
+        return this.runSql(sql);
+    },
+
+    /** Escape table or column name
+        @method */
+    escapeIdentifier: rql.sqlEscapeIdentifier,
+
+    /** @method */
+    runSql: function(sql, values) {
+        return this.backend.runSql(sql, values);
+    },
+
+    /** @method */
+    runSqlAll: function(sql, values) {
+        return this.backend.runSqlAll(sql, values);
+    },
+
+    /**
+     * Parse RQL query
+     * @function
+     */
+    parse: function(query) {
+        return rql.rql2sql(_.rql(query), {table: this.name});
+    }
+});
+
+/** @module sql */
+
+SqlBackend.SqlStore = SqlStore;
+SqlBackend.rql2sql = rql.rql2sql;
+
+module.exports = SqlBackend;
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.1 on Sun Oct 06 2013 18:40:18 GMT+0200 (CEST) +
+ + + + + diff --git a/docs/api/styles/jsdoc-default.css b/docs/api/styles/jsdoc-default.css new file mode 100644 index 0000000..7afd685 --- /dev/null +++ b/docs/api/styles/jsdoc-default.css @@ -0,0 +1,290 @@ +html +{ + overflow: auto; + background-color: #fff; +} + +body +{ + font: 14px "DejaVu Sans Condensed", "Liberation Sans", "Nimbus Sans L", Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans serif; + line-height: 130%; + color: #000; + background-color: #fff; +} + +a { + color: #444; +} + +a:visited { + color: #444; +} + +a:active { + color: #444; +} + +header +{ + display: block; + padding: 6px 4px; +} + +.class-description { + font-style: italic; + font-family: Palatino, 'Palatino Linotype', serif; + font-size: 130%; + line-height: 140%; + margin-bottom: 1em; + margin-top: 1em; +} + +#main { + float: left; + width: 100%; +} + +section +{ + display: block; + + background-color: #fff; + padding: 12px 24px; + border-bottom: 1px solid #ccc; + margin-right: 240px; +} + +.variation { + display: none; +} + +.optional:after { + content: "opt"; + font-size: 60%; + color: #aaa; + font-style: italic; + font-weight: lighter; +} + +nav +{ + display: block; + float: left; + margin-left: -230px; + margin-top: 28px; + width: 220px; + border-left: 1px solid #ccc; + padding-left: 9px; +} + +nav ul { + font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif; + font-size: 100%; + line-height: 17px; + padding:0; + margin:0; + list-style-type:none; +} + +nav h2 a, nav h2 a:visited { + color: #A35A00; + text-decoration: none; +} + +nav h3 { + margin-top: 12px; +} + +nav li { + margin-top: 6px; +} + +nav a { + color: #5C5954; +} + +nav a:visited { + color: #5C5954; +} + +nav a:active { + color: #5C5954; +} + +footer { + display: block; + padding: 6px; + margin-top: 12px; + font-style: italic; + font-size: 90%; +} + +h1 +{ + font-size: 200%; + font-weight: bold; + letter-spacing: -0.01em; + margin: 6px 0 9px 0; +} + +h2 +{ + font-size: 170%; + font-weight: bold; + letter-spacing: -0.01em; + margin: 6px 0 3px 0; +} + +h3 +{ + font-size: 150%; + font-weight: bold; + letter-spacing: -0.01em; + margin-top: 16px; + margin: 6px 0 3px 0; +} + +h4 +{ + font-size: 130%; + font-weight: bold; + letter-spacing: -0.01em; + margin-top: 16px; + margin: 18px 0 3px 0; + color: #A35A00; +} + +h5, .container-overview .subsection-title +{ + font-size: 120%; + font-weight: bold; + letter-spacing: -0.01em; + margin: 8px 0 3px -16px; +} + +h6 +{ + font-size: 100%; + letter-spacing: -0.01em; + margin: 6px 0 3px 0; + font-style: italic; +} + +.ancestors { color: #999; } +.ancestors a +{ + color: #999 !important; + text-decoration: none; +} + +.important +{ + font-weight: bold; + color: #950B02; +} + +.yes-def { + text-indent: -1000px; +} + +.type-signature { + color: #aaa; +} + +.name, .signature { + font-family: Consolas, "Lucida Console", Monaco, monospace; +} + +.details { margin-top: 14px; border-left: 2px solid #DDD; } +.details dt { width:100px; float:left; padding-left: 10px; padding-top: 6px; } +.details dd { margin-left: 50px; } +.details ul { margin: 0; } +.details ul { list-style-type: none; } +.details li { margin-left: 30px; padding-top: 6px; } +.details pre.prettyprint { margin: 0 } +.details .object-value { padding-top: 0; } + +.description { + margin-bottom: 1em; + margin-left: -16px; + margin-top: 1em; +} + +.code-caption +{ + font-style: italic; + font-family: Palatino, 'Palatino Linotype', serif; + font-size: 107%; + margin: 0; +} + +.prettyprint +{ + border: 1px solid #ddd; + width: 80%; + overflow: auto; +} + +.prettyprint.source { + width: inherit; +} + +.prettyprint code +{ + font-family: Consolas, 'Lucida Console', Monaco, monospace; + font-size: 100%; + line-height: 18px; + display: block; + padding: 4px 12px; + margin: 0; + background-color: #fff; + color: #000; + border-left: 3px #ddd solid; +} + +.prettyprint code span.line +{ + display: inline-block; +} + +.params, .props +{ + border-spacing: 0; + border: 0; + border-collapse: collapse; +} + +.params .name, .props .name, .name code { + color: #A35A00; + font-family: Consolas, 'Lucida Console', Monaco, monospace; + font-size: 100%; +} + +.params td, .params th, .props td, .props th +{ + border: 1px solid #ddd; + margin: 0px; + text-align: left; + vertical-align: top; + padding: 4px 6px; + display: table-cell; +} + +.params thead tr, .props thead tr +{ + background-color: #ddd; + font-weight: bold; +} + +.params .params thead tr, .props .props thead tr +{ + background-color: #fff; + font-weight: bold; +} + +.params th, .props th { border-right: 1px solid #aaa; } +.params thead .last, .props thead .last { border-right: 1px solid #ddd; } + +.disabled { + color: #454545; +} diff --git a/docs/api/styles/prettify-jsdoc.css b/docs/api/styles/prettify-jsdoc.css new file mode 100644 index 0000000..5a2526e --- /dev/null +++ b/docs/api/styles/prettify-jsdoc.css @@ -0,0 +1,111 @@ +/* JSDoc prettify.js theme */ + +/* plain text */ +.pln { + color: #000000; + font-weight: normal; + font-style: normal; +} + +/* string content */ +.str { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a keyword */ +.kwd { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* a comment */ +.com { + font-weight: normal; + font-style: italic; +} + +/* a type name */ +.typ { + color: #000000; + font-weight: normal; + font-style: normal; +} + +/* a literal value */ +.lit { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* punctuation */ +.pun { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* lisp open bracket */ +.opn { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* lisp close bracket */ +.clo { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* a markup tag name */ +.tag { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a markup attribute name */ +.atn { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a markup attribute value */ +.atv { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a declaration */ +.dec { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* a variable name */ +.var { + color: #000000; + font-weight: normal; + font-style: normal; +} + +/* a function name */ +.fun { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* Specify class=linenums on a pre to get line numbering */ +ol.linenums { + margin-top: 0; + margin-bottom: 0; +} diff --git a/docs/api/styles/prettify-tomorrow.css b/docs/api/styles/prettify-tomorrow.css new file mode 100644 index 0000000..aa2908c --- /dev/null +++ b/docs/api/styles/prettify-tomorrow.css @@ -0,0 +1,132 @@ +/* Tomorrow Theme */ +/* Original theme - https://github.com/chriskempson/tomorrow-theme */ +/* Pretty printing styles. Used with prettify.js. */ +/* SPAN elements with the classes below are added by prettyprint. */ +/* plain text */ +.pln { + color: #4d4d4c; } + +@media screen { + /* string content */ + .str { + color: #718c00; } + + /* a keyword */ + .kwd { + color: #8959a8; } + + /* a comment */ + .com { + color: #8e908c; } + + /* a type name */ + .typ { + color: #4271ae; } + + /* a literal value */ + .lit { + color: #f5871f; } + + /* punctuation */ + .pun { + color: #4d4d4c; } + + /* lisp open bracket */ + .opn { + color: #4d4d4c; } + + /* lisp close bracket */ + .clo { + color: #4d4d4c; } + + /* a markup tag name */ + .tag { + color: #c82829; } + + /* a markup attribute name */ + .atn { + color: #f5871f; } + + /* a markup attribute value */ + .atv { + color: #3e999f; } + + /* a declaration */ + .dec { + color: #f5871f; } + + /* a variable name */ + .var { + color: #c82829; } + + /* a function name */ + .fun { + color: #4271ae; } } +/* Use higher contrast and text-weight for printable form. */ +@media print, projection { + .str { + color: #060; } + + .kwd { + color: #006; + font-weight: bold; } + + .com { + color: #600; + font-style: italic; } + + .typ { + color: #404; + font-weight: bold; } + + .lit { + color: #044; } + + .pun, .opn, .clo { + color: #440; } + + .tag { + color: #006; + font-weight: bold; } + + .atn { + color: #404; } + + .atv { + color: #060; } } +/* Style */ +/* +pre.prettyprint { + background: white; + font-family: Menlo, Monaco, Consolas, monospace; + font-size: 12px; + line-height: 1.5; + border: 1px solid #ccc; + padding: 10px; } +*/ + +/* Specify class=linenums on a pre to get line numbering */ +ol.linenums { + margin-top: 0; + margin-bottom: 0; } + +/* IE indents via margin-left */ +li.L0, +li.L1, +li.L2, +li.L3, +li.L4, +li.L5, +li.L6, +li.L7, +li.L8, +li.L9 { + /* */ } + +/* Alternate shading for lines */ +li.L1, +li.L3, +li.L5, +li.L7, +li.L9 { + /* */ } diff --git a/make.coffee b/make.coffee new file mode 100644 index 0000000..e4fe7dc --- /dev/null +++ b/make.coffee @@ -0,0 +1,8 @@ +require 'shelljs/make' + +target.all = -> + target.docs() + +target.docs = -> + cd __dirname + exec './node_modules/jsdoc/nodejs/bin/jsdoc -d docs/api backend/*.js' \ No newline at end of file diff --git a/package.json b/package.json index 9385c28..96b0137 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,16 @@ "name": "warehousejs", "version": "0.3.0", "description": "Warehouse.js is a data storage layer node.js and browser providing unified API for many supported storage engines (MongoDB, MySQL, SQLite, in-memory and others). You can create REST server or client with only few lines of code.", - "keywords": ["database", "db", "storage", "mongodb", "mysql", "sqlite", "rest", "rql"], + "keywords": [ + "database", + "db", + "storage", + "mongodb", + "mysql", + "sqlite", + "rest", + "rql" + ], "homepage": "http://github.com/dundalek/warehouse", "author": "Jakub Dundalek (http://dundalek.com/)", "repository": { @@ -16,7 +25,9 @@ "underscore-data": "git://github.com/dundalek/underscore-data.git" }, "devDependencies": { - "qunit": "~0.5.16" + "qunit": "~0.5.16", + "shelljs": "~0.2.6", + "jsdoc": "~3.2.1" }, "optionalDependencies": { "request": "~2.27.0",