betajs-mongodb
Advanced tools
Comparing version 1.0.0 to 1.0.1
/*! | ||
betajs-mongodb - v1.0.0 - 2017-06-08 | ||
betajs-mongodb - v1.0.1 - 2017-06-16 | ||
Copyright (c) Oliver Friedmann | ||
@@ -9,3 +9,3 @@ Apache-2.0 Software License. | ||
var Scoped = this.subScope(); | ||
Scoped.binding('module', 'global:BetaJS.Mongo'); | ||
Scoped.binding('module', 'global:BetaJS.Data.Databases.Mongo'); | ||
Scoped.binding('base', 'global:BetaJS'); | ||
@@ -16,3 +16,3 @@ Scoped.binding('data', 'global:BetaJS.Data'); | ||
"guid": "1f507e0c-602b-4372-b067-4e19442f28f4", | ||
"version": "1.0.0" | ||
"version": "1.0.1" | ||
}; | ||
@@ -22,3 +22,3 @@ }); | ||
Scoped.assumeVersion('data:version', '~1.0.41'); | ||
Scoped.define("module:Databases.MongoDatabaseTable", [ | ||
Scoped.define("module:MongoDatabaseTable", [ | ||
"data:Databases.DatabaseTable", | ||
@@ -123,5 +123,5 @@ "base:Promise", | ||
}); | ||
Scoped.define("module:Databases.MongoDatabase", [ | ||
Scoped.define("module:MongoDatabase", [ | ||
"data:Databases.Database", | ||
"module:Databases.MongoDatabaseTable", | ||
"module:MongoDatabaseTable", | ||
"base:Strings", | ||
@@ -128,0 +128,0 @@ "base:Types", |
/*! | ||
betajs-mongodb - v1.0.0 - 2017-06-08 | ||
betajs-mongodb - v1.0.1 - 2017-06-16 | ||
Copyright (c) Oliver Friedmann | ||
@@ -7,2 +7,2 @@ Apache-2.0 Software License. | ||
(function(){var a=this.subScope();a.binding("module","global:BetaJS.Mongo"),a.binding("base","global:BetaJS"),a.binding("data","global:BetaJS.Data"),a.define("module:",function(){return{guid:"1f507e0c-602b-4372-b067-4e19442f28f4",version:"1.0.0"}}),a.assumeVersion("base:version","~1.0.96"),a.assumeVersion("data:version","~1.0.41"),a.define("module:Databases.MongoDatabaseTable",["data:Databases.DatabaseTable","base:Promise","base:Objs","base:Types","base:Iterators.ArrayIterator"],function(a,b,c,d,e,f){return a.extend({scoped:f},{table:function(){return this.__table?b.create(this.__table):this._database.mongodb().mapSuccess(function(a){return this.__table=a.collection(this._table_name),this.__table},this)},primary_key:function(){return"_id"},_encode:function(a){if(a._id&&!d.is_object(a._id)){a=c.clone(a,1);var b=this._database.mongo_object_id();a._id=new b(a._id+"")}return a},_decode:function(a){return a._id&&d.is_object(a._id)&&(a=c.clone(a,1),a._id=a._id+""),a},_find:function(a,c){return this.table().mapSuccess(function(d){return b.funcCallback(d,d.find,a).mapSuccess(function(a){return c=c||{},"sort"in c&&(a=a.sort(c.sort)),"skip"in c&&(a=a.skip(c.skip)),"limit"in c&&(a=a.limit(c.limit)),b.funcCallback(a,a.toArray).mapSuccess(function(a){return new e(a)},this)},this)},this)},_count:function(a){return this.table().mapSuccess(function(c){return b.funcCallback(c,c.find,a).mapSuccess(function(a){return b.funcCallback(a,a.count)})})},_insertRow:function(a){return this.table().mapSuccess(function(c){return b.funcCallback(c,c.insert,a).mapSuccess(function(b){return a},this)},this)},_removeRow:function(a,c){return this.table().mapSuccess(function(c){return b.funcCallback(c,c.remove,a)},this)},_updateRow:function(a,c,d){return this.table().mapSuccess(function(d){return b.funcCallback(d,d.update,a,{$set:c}).mapSuccess(function(){return c})},this)},ensureIndex:function(a){({})[a]=1,this.table().success(function(b){b.ensureIndex(c.objectBy(a,1))})}})}),a.define("module:Databases.MongoDatabase",["data:Databases.Database","module:Databases.MongoDatabaseTable","base:Strings","base:Types","base:Objs","base:Promise","base:Net.Uri"],function(a,b,c,d,e,f,g,h){return a.extend({scoped:h},function(a){return{constructor:function(b){d.is_string(b)?(this.__dbUri=c.strip_start(b,"mongodb://"),this.__dbObject=this.cls.uriToObject(b)):(b=e.extend({database:"database",server:"localhost",port:27017},b),this.__dbObject=b,this.__dbUri=this.cls.objectToUri(b)),a.constructor.call(this),this.mongo_module=require("mongodb")},_tableClass:function(){return b},mongo_object_id:function(a){return this.mongo_module.ObjectID},mongodb:function(){if(this.__mongodb)return f.value(this.__mongodb);var a=f.create();return this.mongo_module.MongoClient.connect("mongodb://"+this.__dbUri,{server:{auto_reconnect:!0}},a.asyncCallbackFunc()),a.success(function(a){this.__mongodb=a},this)}}},{uriToObject:function(a){var b=g.parse(a);return{database:c.strip_start(b.path,"/"),server:b.host,port:b.port,username:b.user,password:b.password}},objectToUri:function(a){return a.path=a.database,g.build(a)}})})}).call(Scoped); | ||
(function(){var a=this.subScope();a.binding("module","global:BetaJS.Data.Databases.Mongo"),a.binding("base","global:BetaJS"),a.binding("data","global:BetaJS.Data"),a.define("module:",function(){return{guid:"1f507e0c-602b-4372-b067-4e19442f28f4",version:"1.0.1"}}),a.assumeVersion("base:version","~1.0.96"),a.assumeVersion("data:version","~1.0.41"),a.define("module:MongoDatabaseTable",["data:Databases.DatabaseTable","base:Promise","base:Objs","base:Types","base:Iterators.ArrayIterator"],function(a,b,c,d,e,f){return a.extend({scoped:f},{table:function(){return this.__table?b.create(this.__table):this._database.mongodb().mapSuccess(function(a){return this.__table=a.collection(this._table_name),this.__table},this)},primary_key:function(){return"_id"},_encode:function(a){if(a._id&&!d.is_object(a._id)){a=c.clone(a,1);var b=this._database.mongo_object_id();a._id=new b(a._id+"")}return a},_decode:function(a){return a._id&&d.is_object(a._id)&&(a=c.clone(a,1),a._id=a._id+""),a},_find:function(a,c){return this.table().mapSuccess(function(d){return b.funcCallback(d,d.find,a).mapSuccess(function(a){return c=c||{},"sort"in c&&(a=a.sort(c.sort)),"skip"in c&&(a=a.skip(c.skip)),"limit"in c&&(a=a.limit(c.limit)),b.funcCallback(a,a.toArray).mapSuccess(function(a){return new e(a)},this)},this)},this)},_count:function(a){return this.table().mapSuccess(function(c){return b.funcCallback(c,c.find,a).mapSuccess(function(a){return b.funcCallback(a,a.count)})})},_insertRow:function(a){return this.table().mapSuccess(function(c){return b.funcCallback(c,c.insert,a).mapSuccess(function(b){return a},this)},this)},_removeRow:function(a,c){return this.table().mapSuccess(function(c){return b.funcCallback(c,c.remove,a)},this)},_updateRow:function(a,c,d){return this.table().mapSuccess(function(d){return b.funcCallback(d,d.update,a,{$set:c}).mapSuccess(function(){return c})},this)},ensureIndex:function(a){({})[a]=1,this.table().success(function(b){b.ensureIndex(c.objectBy(a,1))})}})}),a.define("module:MongoDatabase",["data:Databases.Database","module:MongoDatabaseTable","base:Strings","base:Types","base:Objs","base:Promise","base:Net.Uri"],function(a,b,c,d,e,f,g,h){return a.extend({scoped:h},function(a){return{constructor:function(b){d.is_string(b)?(this.__dbUri=c.strip_start(b,"mongodb://"),this.__dbObject=this.cls.uriToObject(b)):(b=e.extend({database:"database",server:"localhost",port:27017},b),this.__dbObject=b,this.__dbUri=this.cls.objectToUri(b)),a.constructor.call(this),this.mongo_module=require("mongodb")},_tableClass:function(){return b},mongo_object_id:function(a){return this.mongo_module.ObjectID},mongodb:function(){if(this.__mongodb)return f.value(this.__mongodb);var a=f.create();return this.mongo_module.MongoClient.connect("mongodb://"+this.__dbUri,{server:{auto_reconnect:!0}},a.asyncCallbackFunc()),a.success(function(a){this.__mongodb=a},this)}}},{uriToObject:function(a){var b=g.parse(a);return{database:c.strip_start(b.path,"/"),server:b.host,port:b.port,username:b.user,password:b.password}},objectToUri:function(a){return a.path=a.database,g.build(a)}})})}).call(Scoped); |
/*! | ||
betajs-mongodb - v1.0.0 - 2017-06-08 | ||
betajs-mongodb - v1.0.1 - 2017-06-16 | ||
Copyright (c) Oliver Friedmann | ||
@@ -1007,3 +1007,3 @@ Apache-2.0 Software License. | ||
/*! | ||
betajs-mongodb - v1.0.0 - 2017-06-08 | ||
betajs-mongodb - v1.0.1 - 2017-06-16 | ||
Copyright (c) Oliver Friedmann | ||
@@ -1015,3 +1015,3 @@ Apache-2.0 Software License. | ||
var Scoped = this.subScope(); | ||
Scoped.binding('module', 'global:BetaJS.Mongo'); | ||
Scoped.binding('module', 'global:BetaJS.Data.Databases.Mongo'); | ||
Scoped.binding('base', 'global:BetaJS'); | ||
@@ -1022,3 +1022,3 @@ Scoped.binding('data', 'global:BetaJS.Data'); | ||
"guid": "1f507e0c-602b-4372-b067-4e19442f28f4", | ||
"version": "1.0.0" | ||
"version": "1.0.1" | ||
}; | ||
@@ -1028,3 +1028,3 @@ }); | ||
Scoped.assumeVersion('data:version', '~1.0.41'); | ||
Scoped.define("module:Databases.MongoDatabaseTable", [ | ||
Scoped.define("module:MongoDatabaseTable", [ | ||
"data:Databases.DatabaseTable", | ||
@@ -1129,5 +1129,5 @@ "base:Promise", | ||
}); | ||
Scoped.define("module:Databases.MongoDatabase", [ | ||
Scoped.define("module:MongoDatabase", [ | ||
"data:Databases.Database", | ||
"module:Databases.MongoDatabaseTable", | ||
"module:MongoDatabaseTable", | ||
"base:Strings", | ||
@@ -1134,0 +1134,0 @@ "base:Types", |
/*! | ||
betajs-mongodb - v1.0.0 - 2017-06-08 | ||
betajs-mongodb - v1.0.1 - 2017-06-16 | ||
Copyright (c) Oliver Friedmann | ||
@@ -7,2 +7,2 @@ Apache-2.0 Software License. | ||
var Scoped=function(){function a(a){function b(a){return{route:"string"==typeof a.route?a.route:null,parent:"object"==typeof a.parent?a.parent:null,ready:"boolean"==typeof a.ready&&a.ready,children:{},watchers:[],data:{},lazy:[]}}function c(a){if(!a.ready){if(a.parent&&!a.parent.ready)return void c(a.parent);if(a.route&&a.parent&&a.route in a.parent.data){a.data=a.parent.data[a.route],a.ready=!0;for(var b=0;b<a.watchers.length;++b)a.watchers[b].callback.call(a.watchers[b].context||this,a.data);a.watchers=[];for(var d in a.children)c(a.children[d])}}}function d(a){if(!a.ready){a.parent&&!a.parent.ready&&d(a.parent),a.ready=!0,a.parent&&j.tree&&"object"==typeof a.parent.data&&(a.parent.data[a.route]=a.data);for(var b=0;b<a.watchers.length;++b)a.watchers[b].callback.call(a.watchers[b].context||this,a.data);a.watchers=[]}}function e(a,b){if("object"==typeof b&&a.ready)for(var e in b)a.data[e]=b[e];else a.data=b;if("object"==typeof b)for(var f in b)a.children[f]&&(a.children[f].data=b[f]);d(a);for(var g in a.children)c(a.children[g])}function f(a){if(a.ready&&a.data)for(var b in a.data)delete a.data[b]}function g(a){if(!a)return k;for(var d=a.split("."),e=k,f=0;f<d.length;++f)d[f]in e.children?e=e.children[d[f]]:(e.children[d[f]]=b({parent:e,route:d[f]}),e=e.children[d[f]],c(e));return e}function h(a,b,c){if(a.ready)b.call(c||this,a.data);else if(a.watchers.push({callback:b,context:c}),a.lazy.length>0){var d=function(a){if(a.lazy.length>0){var b=a.lazy.shift();b.callback.call(b.context||this,a.data),d(a)}};d(a)}}function i(a,b,c){a=a||k,c=c||[],a.ready||c.push(b);for(var d in a.children){var e=a.children[d];c=i(e,(b?b+".":"")+e.route,c)}return c}var j={tree:"boolean"==typeof a.tree&&a.tree,global:"boolean"==typeof a.global&&a.global,root:"object"==typeof a.root?a.root:{}},k=b({ready:!0});if(j.tree)if(j.global){try{window&&(k.data=window)}catch(l){}try{global&&(k.data=global)}catch(l){}try{self&&(k.data=self)}catch(l){}}else k.data=j.root;return{extend:function(a,b){e(g(a),b)},set:function(a,b){var c=g(a);c.data&&f(c),e(c,b)},get:function(a){var b=g(a);return b.ready?b.data:null},lazy:function(a,b,c){var d=g(a);d.ready?b(c||this,d.data):d.lazy.push({callback:b,context:c})},digest:function(a){c(g(a))},obtain:function(a,b,c){h(g(a),b,c)},unresolvedWatchers:function(a){return i(g(a),a)},__export:function(){return{options:j,nsRoot:k}},__import:function(a){j=a.options,k=a.nsRoot}}}function b(e,f,g,h){var i=null,j=[],k=f,l=g,m=h,n=a({tree:!0}),o=a({tree:!1}),p={global:{namespace:m},root:{namespace:l},local:{namespace:n},"default":{namespace:o},parent:{namespace:k},scope:{namespace:n,readonly:!1}},q=function(a,b,c){var e=d.matchArgs(a,{options:"object",namespaceLocator:!0,dependencies:"array",hiddenDependencies:"array",callback:!0,context:"object"}),f=d.extend({lazy:this.options.lazy},e.options||{}),g=this.resolve(e.namespaceLocator),h=function(){this.require(e.dependencies,e.hiddenDependencies,function(){if(arguments[arguments.length-1].ns=g,this.options.compile){for(var f=[],h=0;h<a.length;++h)f.push(d.stringify(a[h]));this.compiled+=this.options.ident+"."+b+"("+f.join(", ")+");\n\n"}this.options.dependencies&&(this.dependencies[g.path]=this.dependencies[g.path]||{},e.dependencies&&e.dependencies.forEach(function(a){this.dependencies[g.path][this.resolve(a).path]=!0},this),e.hiddenDependencies&&e.hiddenDependencies.forEach(function(a){this.dependencies[g.path][this.resolve(a).path]=!0},this));var i=this.options.compile?{}:e.callback.apply(e.context||this,arguments);c.call(this,g,i)},this)};return f.lazy?g.namespace.lazy(g.path,h,this):h.apply(this),this};return{getGlobal:d.method(c,c.getPath),setGlobal:d.method(c,c.setPath),options:{lazy:!1,ident:"Scoped",compile:!1,dependencies:!1},compiled:"",dependencies:{},nextScope:function(){return i||(i=b(this,n,l,m)),i},subScope:function(){var a=this.nextScope();return j.push(a),i=null,a},binding:function(b,c,e){if(!p[b]||!p[b].readonly){var f;f="string"!=d.typeOf(c)?{namespace:a({tree:!0,root:c}),path:null}:this.resolve(c),p[b]=d.extend(e,f)}return this},resolve:function(a){var b=a.split(":");if(1==b.length)return{namespace:o,path:b[0]};var c=p[b[0]];if(!c)throw"The namespace '"+b[0]+"' has not been defined (yet).";return{namespace:c.namespace,path:c.path&&b[1]?c.path+"."+b[1]:c.path||b[1]}},define:function(){return q.call(this,arguments,"define",function(a,b){if(a.namespace.get(a.path))throw"Scoped namespace "+a.path+" has already been defined. Use extend to extend an existing namespace instead";a.namespace.set(a.path,b)})},assumeVersion:function(){var a=d.matchArgs(arguments,{assumption:!0,dependencies:"array",callback:!0,context:"object",error:"string"}),b=a.dependencies||[];b.unshift(a.assumption),this.require(b,function(){var b=arguments,c=b[0].replace(/[^\d\.]/g,"");b[0]=c.split(".");for(var e=0;e<b[0].length;++e)b[0][e]=parseInt(b[0][e],10);if("function"===d.typeOf(a.callback)){if(!a.callback.apply(a.context||this,a))throw"Scoped Assumption '"+a.assumption+"' failed, value is "+c+(a.error?", but assuming "+a.error:"")}else for(var f=(a.callback+"").replace(/[^\d\.]/g,"").split("."),g=0;g<Math.min(b[0].length,f.length);++g)if(parseInt(f[g],10)>b[0][g])throw"Scoped Version Assumption '"+a.assumption+"' failed, value is "+c+", but assuming at least "+a.callback})},extend:function(){return q.call(this,arguments,"extend",function(a,b){a.namespace.extend(a.path,b)})},require:function(){var a=d.matchArgs(arguments,{dependencies:"array",hiddenDependencies:"array",callback:"function",context:"object"});a.callback=a.callback||function(){};var b=a.dependencies||[],c=b.concat(a.hiddenDependencies||[]),e=c.length,f=[],g={};if(e)for(var h=function(b){this.i<f.length&&(f[this.i]=b),0===--e&&(f.push(g),a.callback.apply(a.context||this.ctx,f))},i=0;i<c.length;++i){var j=this.resolve(c[i]);i<b.length&&f.push(null),j.namespace.obtain(j.path,h,{ctx:this,i:i})}else f.push(g),a.callback.apply(a.context||this,f);return this},digest:function(a){var b=this.resolve(a);return b.namespace.digest(b.path),this},unresolved:function(a){var b=this.resolve(a);return b.namespace.unresolvedWatchers(b.path)},__export:function(){return{parentNamespace:k.__export(),rootNamespace:l.__export(),globalNamespace:m.__export(),localNamespace:n.__export(),privateNamespace:o.__export()}},__import:function(a){k.__import(a.parentNamespace),l.__import(a.rootNamespace),m.__import(a.globalNamespace),n.__import(a.localNamespace),o.__import(a.privateNamespace)}}}var c=function(){return{get:function(a){return"undefined"!=typeof window?window[a]:"undefined"!=typeof global?global[a]:"undefined"!=typeof self?self[a]:undefined},set:function(a,b){return"undefined"!=typeof window&&(window[a]=b),"undefined"!=typeof global&&(global[a]=b),"undefined"!=typeof self&&(self[a]=b),b},getPath:function(a){var b=a.split(".");if(1==b.length)return this.get(a);for(var c=this.get(b[0]),d=1;d<b.length;++d){if(!c)return c;c=c[b[d]]}return c},setPath:function(a,b){var c=a.split(".");if(1==c.length)return this.set(a,b);for(var d=this.get(c[0])||this.set(c[0],{}),e=1;e<c.length-1;++e)c[e]in d||(d[c[e]]={}),d=d[c[e]];return d[c[c.length-1]]=b,b}}}.call(this),d=function(){return{method:function(a,b){return function(){return b.apply(a,arguments)}},extend:function(a,b){a=a||{},b=b||{};for(var c in b)a[c]=b[c];return a},typeOf:function(a){return"[object Array]"===Object.prototype.toString.call(a)?"array":typeof a},isEmpty:function(a){if(null===a||void 0===a)return!0;if("array"==this.typeOf(a))return 0===a.length;if("object"!=typeof a)return!1;for(var b in a)return!1;return!0},matchArgs:function(a,b){var c=0,d={};for(var e in b)!0===b[e]||this.typeOf(a[c])==b[e]?(d[e]=a[c],c++):"undefined"==this.typeOf(a[c])&&c++;return d},stringify:function(a){return"function"==this.typeOf(a)?""+a:JSON.stringify(a)}}}.call(this),e=function(){return{__namespace:"Scoped",__revert:null,upgrade:function(a){var b=c.get(a||e.__namespace);if(b&&"object"==d.typeOf(b)&&b.guid==this.guid&&"string"==d.typeOf(b.version)){for(var f=this.version.split("."),g=b.version.split("."),h=!1,i=0;i<Math.min(f.length,g.length)&&(h=parseInt(f[i],10)>parseInt(g[i],10),f[i]==g[i]);++i);return h?this.attach(a):b}return this.attach(a)},attach:function(a){a&&(e.__namespace=a);var b=c.get(e.__namespace);if(b==this)return this;if(e.__revert=b,b)try{var d=b.__exportScoped();this.__exportBackup=this.__exportScoped(),this.__importScoped(d)}catch(f){}return c.set(e.__namespace,this),this},detach:function(a){return a&&c.set(e.__namespace,null),"undefined"!=typeof e.__revert&&c.set(e.__namespace,e.__revert),delete e.__revert,e.__exportBackup&&this.__importScoped(e.__exportBackup),this},exports:function(a,b,c){return a=a||("undefined"!=typeof module?module:null),"object"==typeof a&&a&&"exports"in a&&(c||a.exports==this||!a.exports||d.isEmpty(a.exports))&&(a.exports=b||this),this}}}.call(this),f=a({tree:!0,global:!0}),g=a({tree:!0}),h=b(null,g,g,f),i=d.extend(h,function(){return{guid:"4b6878ee-cb6a-46b3-94ac-27d91f58d666",version:"0.0.13",upgrade:e.upgrade,attach:e.attach,detach:e.detach,exports:e.exports,__exportScoped:function(){return{globalNamespace:f.__export(),rootNamespace:g.__export(),rootScope:h.__export()}},__importScoped:function(a){f.__import(a.globalNamespace),g.__import(a.rootNamespace),h.__import(a.rootScope)}}}.call(this));return i=i.upgrade(),i.exports(),i}.call(this);(function(){var a=this.subScope();a.binding("module","global:BetaJS.Mongo"),a.binding("base","global:BetaJS"),a.binding("data","global:BetaJS.Data"),a.define("module:",function(){return{guid:"1f507e0c-602b-4372-b067-4e19442f28f4",version:"1.0.0"}}),a.assumeVersion("base:version","~1.0.96"),a.assumeVersion("data:version","~1.0.41"),a.define("module:Databases.MongoDatabaseTable",["data:Databases.DatabaseTable","base:Promise","base:Objs","base:Types","base:Iterators.ArrayIterator"],function(a,b,c,d,e,f){return a.extend({scoped:f},{table:function(){return this.__table?b.create(this.__table):this._database.mongodb().mapSuccess(function(a){return this.__table=a.collection(this._table_name),this.__table},this)},primary_key:function(){return"_id"},_encode:function(a){if(a._id&&!d.is_object(a._id)){a=c.clone(a,1);var b=this._database.mongo_object_id();a._id=new b(a._id+"")}return a},_decode:function(a){return a._id&&d.is_object(a._id)&&(a=c.clone(a,1),a._id=a._id+""),a},_find:function(a,c){return this.table().mapSuccess(function(d){return b.funcCallback(d,d.find,a).mapSuccess(function(a){return c=c||{},"sort"in c&&(a=a.sort(c.sort)),"skip"in c&&(a=a.skip(c.skip)),"limit"in c&&(a=a.limit(c.limit)),b.funcCallback(a,a.toArray).mapSuccess(function(a){return new e(a)},this)},this)},this)},_count:function(a){return this.table().mapSuccess(function(c){return b.funcCallback(c,c.find,a).mapSuccess(function(a){return b.funcCallback(a,a.count)})})},_insertRow:function(a){return this.table().mapSuccess(function(c){return b.funcCallback(c,c.insert,a).mapSuccess(function(b){return a},this)},this)},_removeRow:function(a,c){return this.table().mapSuccess(function(c){return b.funcCallback(c,c.remove,a)},this)},_updateRow:function(a,c,d){return this.table().mapSuccess(function(d){return b.funcCallback(d,d.update,a,{$set:c}).mapSuccess(function(){return c})},this)},ensureIndex:function(a){({})[a]=1,this.table().success(function(b){b.ensureIndex(c.objectBy(a,1))})}})}),a.define("module:Databases.MongoDatabase",["data:Databases.Database","module:Databases.MongoDatabaseTable","base:Strings","base:Types","base:Objs","base:Promise","base:Net.Uri"],function(a,b,c,d,e,f,g,h){return a.extend({scoped:h},function(a){return{constructor:function(b){d.is_string(b)?(this.__dbUri=c.strip_start(b,"mongodb://"),this.__dbObject=this.cls.uriToObject(b)):(b=e.extend({database:"database",server:"localhost",port:27017},b),this.__dbObject=b,this.__dbUri=this.cls.objectToUri(b)),a.constructor.call(this),this.mongo_module=require("mongodb")},_tableClass:function(){return b},mongo_object_id:function(a){return this.mongo_module.ObjectID},mongodb:function(){if(this.__mongodb)return f.value(this.__mongodb);var a=f.create();return this.mongo_module.MongoClient.connect("mongodb://"+this.__dbUri,{server:{auto_reconnect:!0}},a.asyncCallbackFunc()),a.success(function(a){this.__mongodb=a},this)}}},{uriToObject:function(a){var b=g.parse(a);return{database:c.strip_start(b.path,"/"),server:b.host,port:b.port,username:b.user,password:b.password}},objectToUri:function(a){return a.path=a.database,g.build(a)}})})}).call(Scoped); | ||
var Scoped=function(){function a(a){function b(a){return{route:"string"==typeof a.route?a.route:null,parent:"object"==typeof a.parent?a.parent:null,ready:"boolean"==typeof a.ready&&a.ready,children:{},watchers:[],data:{},lazy:[]}}function c(a){if(!a.ready){if(a.parent&&!a.parent.ready)return void c(a.parent);if(a.route&&a.parent&&a.route in a.parent.data){a.data=a.parent.data[a.route],a.ready=!0;for(var b=0;b<a.watchers.length;++b)a.watchers[b].callback.call(a.watchers[b].context||this,a.data);a.watchers=[];for(var d in a.children)c(a.children[d])}}}function d(a){if(!a.ready){a.parent&&!a.parent.ready&&d(a.parent),a.ready=!0,a.parent&&j.tree&&"object"==typeof a.parent.data&&(a.parent.data[a.route]=a.data);for(var b=0;b<a.watchers.length;++b)a.watchers[b].callback.call(a.watchers[b].context||this,a.data);a.watchers=[]}}function e(a,b){if("object"==typeof b&&a.ready)for(var e in b)a.data[e]=b[e];else a.data=b;if("object"==typeof b)for(var f in b)a.children[f]&&(a.children[f].data=b[f]);d(a);for(var g in a.children)c(a.children[g])}function f(a){if(a.ready&&a.data)for(var b in a.data)delete a.data[b]}function g(a){if(!a)return k;for(var d=a.split("."),e=k,f=0;f<d.length;++f)d[f]in e.children?e=e.children[d[f]]:(e.children[d[f]]=b({parent:e,route:d[f]}),e=e.children[d[f]],c(e));return e}function h(a,b,c){if(a.ready)b.call(c||this,a.data);else if(a.watchers.push({callback:b,context:c}),a.lazy.length>0){var d=function(a){if(a.lazy.length>0){var b=a.lazy.shift();b.callback.call(b.context||this,a.data),d(a)}};d(a)}}function i(a,b,c){a=a||k,c=c||[],a.ready||c.push(b);for(var d in a.children){var e=a.children[d];c=i(e,(b?b+".":"")+e.route,c)}return c}var j={tree:"boolean"==typeof a.tree&&a.tree,global:"boolean"==typeof a.global&&a.global,root:"object"==typeof a.root?a.root:{}},k=b({ready:!0});if(j.tree)if(j.global){try{window&&(k.data=window)}catch(l){}try{global&&(k.data=global)}catch(l){}try{self&&(k.data=self)}catch(l){}}else k.data=j.root;return{extend:function(a,b){e(g(a),b)},set:function(a,b){var c=g(a);c.data&&f(c),e(c,b)},get:function(a){var b=g(a);return b.ready?b.data:null},lazy:function(a,b,c){var d=g(a);d.ready?b(c||this,d.data):d.lazy.push({callback:b,context:c})},digest:function(a){c(g(a))},obtain:function(a,b,c){h(g(a),b,c)},unresolvedWatchers:function(a){return i(g(a),a)},__export:function(){return{options:j,nsRoot:k}},__import:function(a){j=a.options,k=a.nsRoot}}}function b(e,f,g,h){var i=null,j=[],k=f,l=g,m=h,n=a({tree:!0}),o=a({tree:!1}),p={global:{namespace:m},root:{namespace:l},local:{namespace:n},"default":{namespace:o},parent:{namespace:k},scope:{namespace:n,readonly:!1}},q=function(a,b,c){var e=d.matchArgs(a,{options:"object",namespaceLocator:!0,dependencies:"array",hiddenDependencies:"array",callback:!0,context:"object"}),f=d.extend({lazy:this.options.lazy},e.options||{}),g=this.resolve(e.namespaceLocator),h=function(){this.require(e.dependencies,e.hiddenDependencies,function(){if(arguments[arguments.length-1].ns=g,this.options.compile){for(var f=[],h=0;h<a.length;++h)f.push(d.stringify(a[h]));this.compiled+=this.options.ident+"."+b+"("+f.join(", ")+");\n\n"}this.options.dependencies&&(this.dependencies[g.path]=this.dependencies[g.path]||{},e.dependencies&&e.dependencies.forEach(function(a){this.dependencies[g.path][this.resolve(a).path]=!0},this),e.hiddenDependencies&&e.hiddenDependencies.forEach(function(a){this.dependencies[g.path][this.resolve(a).path]=!0},this));var i=this.options.compile?{}:e.callback.apply(e.context||this,arguments);c.call(this,g,i)},this)};return f.lazy?g.namespace.lazy(g.path,h,this):h.apply(this),this};return{getGlobal:d.method(c,c.getPath),setGlobal:d.method(c,c.setPath),options:{lazy:!1,ident:"Scoped",compile:!1,dependencies:!1},compiled:"",dependencies:{},nextScope:function(){return i||(i=b(this,n,l,m)),i},subScope:function(){var a=this.nextScope();return j.push(a),i=null,a},binding:function(b,c,e){if(!p[b]||!p[b].readonly){var f;f="string"!=d.typeOf(c)?{namespace:a({tree:!0,root:c}),path:null}:this.resolve(c),p[b]=d.extend(e,f)}return this},resolve:function(a){var b=a.split(":");if(1==b.length)return{namespace:o,path:b[0]};var c=p[b[0]];if(!c)throw"The namespace '"+b[0]+"' has not been defined (yet).";return{namespace:c.namespace,path:c.path&&b[1]?c.path+"."+b[1]:c.path||b[1]}},define:function(){return q.call(this,arguments,"define",function(a,b){if(a.namespace.get(a.path))throw"Scoped namespace "+a.path+" has already been defined. Use extend to extend an existing namespace instead";a.namespace.set(a.path,b)})},assumeVersion:function(){var a=d.matchArgs(arguments,{assumption:!0,dependencies:"array",callback:!0,context:"object",error:"string"}),b=a.dependencies||[];b.unshift(a.assumption),this.require(b,function(){var b=arguments,c=b[0].replace(/[^\d\.]/g,"");b[0]=c.split(".");for(var e=0;e<b[0].length;++e)b[0][e]=parseInt(b[0][e],10);if("function"===d.typeOf(a.callback)){if(!a.callback.apply(a.context||this,a))throw"Scoped Assumption '"+a.assumption+"' failed, value is "+c+(a.error?", but assuming "+a.error:"")}else for(var f=(a.callback+"").replace(/[^\d\.]/g,"").split("."),g=0;g<Math.min(b[0].length,f.length);++g)if(parseInt(f[g],10)>b[0][g])throw"Scoped Version Assumption '"+a.assumption+"' failed, value is "+c+", but assuming at least "+a.callback})},extend:function(){return q.call(this,arguments,"extend",function(a,b){a.namespace.extend(a.path,b)})},require:function(){var a=d.matchArgs(arguments,{dependencies:"array",hiddenDependencies:"array",callback:"function",context:"object"});a.callback=a.callback||function(){};var b=a.dependencies||[],c=b.concat(a.hiddenDependencies||[]),e=c.length,f=[],g={};if(e)for(var h=function(b){this.i<f.length&&(f[this.i]=b),0===--e&&(f.push(g),a.callback.apply(a.context||this.ctx,f))},i=0;i<c.length;++i){var j=this.resolve(c[i]);i<b.length&&f.push(null),j.namespace.obtain(j.path,h,{ctx:this,i:i})}else f.push(g),a.callback.apply(a.context||this,f);return this},digest:function(a){var b=this.resolve(a);return b.namespace.digest(b.path),this},unresolved:function(a){var b=this.resolve(a);return b.namespace.unresolvedWatchers(b.path)},__export:function(){return{parentNamespace:k.__export(),rootNamespace:l.__export(),globalNamespace:m.__export(),localNamespace:n.__export(),privateNamespace:o.__export()}},__import:function(a){k.__import(a.parentNamespace),l.__import(a.rootNamespace),m.__import(a.globalNamespace),n.__import(a.localNamespace),o.__import(a.privateNamespace)}}}var c=function(){return{get:function(a){return"undefined"!=typeof window?window[a]:"undefined"!=typeof global?global[a]:"undefined"!=typeof self?self[a]:undefined},set:function(a,b){return"undefined"!=typeof window&&(window[a]=b),"undefined"!=typeof global&&(global[a]=b),"undefined"!=typeof self&&(self[a]=b),b},getPath:function(a){var b=a.split(".");if(1==b.length)return this.get(a);for(var c=this.get(b[0]),d=1;d<b.length;++d){if(!c)return c;c=c[b[d]]}return c},setPath:function(a,b){var c=a.split(".");if(1==c.length)return this.set(a,b);for(var d=this.get(c[0])||this.set(c[0],{}),e=1;e<c.length-1;++e)c[e]in d||(d[c[e]]={}),d=d[c[e]];return d[c[c.length-1]]=b,b}}}.call(this),d=function(){return{method:function(a,b){return function(){return b.apply(a,arguments)}},extend:function(a,b){a=a||{},b=b||{};for(var c in b)a[c]=b[c];return a},typeOf:function(a){return"[object Array]"===Object.prototype.toString.call(a)?"array":typeof a},isEmpty:function(a){if(null===a||void 0===a)return!0;if("array"==this.typeOf(a))return 0===a.length;if("object"!=typeof a)return!1;for(var b in a)return!1;return!0},matchArgs:function(a,b){var c=0,d={};for(var e in b)!0===b[e]||this.typeOf(a[c])==b[e]?(d[e]=a[c],c++):"undefined"==this.typeOf(a[c])&&c++;return d},stringify:function(a){return"function"==this.typeOf(a)?""+a:JSON.stringify(a)}}}.call(this),e=function(){return{__namespace:"Scoped",__revert:null,upgrade:function(a){var b=c.get(a||e.__namespace);if(b&&"object"==d.typeOf(b)&&b.guid==this.guid&&"string"==d.typeOf(b.version)){for(var f=this.version.split("."),g=b.version.split("."),h=!1,i=0;i<Math.min(f.length,g.length)&&(h=parseInt(f[i],10)>parseInt(g[i],10),f[i]==g[i]);++i);return h?this.attach(a):b}return this.attach(a)},attach:function(a){a&&(e.__namespace=a);var b=c.get(e.__namespace);if(b==this)return this;if(e.__revert=b,b)try{var d=b.__exportScoped();this.__exportBackup=this.__exportScoped(),this.__importScoped(d)}catch(f){}return c.set(e.__namespace,this),this},detach:function(a){return a&&c.set(e.__namespace,null),"undefined"!=typeof e.__revert&&c.set(e.__namespace,e.__revert),delete e.__revert,e.__exportBackup&&this.__importScoped(e.__exportBackup),this},exports:function(a,b,c){return a=a||("undefined"!=typeof module?module:null),"object"==typeof a&&a&&"exports"in a&&(c||a.exports==this||!a.exports||d.isEmpty(a.exports))&&(a.exports=b||this),this}}}.call(this),f=a({tree:!0,global:!0}),g=a({tree:!0}),h=b(null,g,g,f),i=d.extend(h,function(){return{guid:"4b6878ee-cb6a-46b3-94ac-27d91f58d666",version:"0.0.13",upgrade:e.upgrade,attach:e.attach,detach:e.detach,exports:e.exports,__exportScoped:function(){return{globalNamespace:f.__export(),rootNamespace:g.__export(),rootScope:h.__export()}},__importScoped:function(a){f.__import(a.globalNamespace),g.__import(a.rootNamespace),h.__import(a.rootScope)}}}.call(this));return i=i.upgrade(),i.exports(),i}.call(this);(function(){var a=this.subScope();a.binding("module","global:BetaJS.Data.Databases.Mongo"),a.binding("base","global:BetaJS"),a.binding("data","global:BetaJS.Data"),a.define("module:",function(){return{guid:"1f507e0c-602b-4372-b067-4e19442f28f4",version:"1.0.1"}}),a.assumeVersion("base:version","~1.0.96"),a.assumeVersion("data:version","~1.0.41"),a.define("module:MongoDatabaseTable",["data:Databases.DatabaseTable","base:Promise","base:Objs","base:Types","base:Iterators.ArrayIterator"],function(a,b,c,d,e,f){return a.extend({scoped:f},{table:function(){return this.__table?b.create(this.__table):this._database.mongodb().mapSuccess(function(a){return this.__table=a.collection(this._table_name),this.__table},this)},primary_key:function(){return"_id"},_encode:function(a){if(a._id&&!d.is_object(a._id)){a=c.clone(a,1);var b=this._database.mongo_object_id();a._id=new b(a._id+"")}return a},_decode:function(a){return a._id&&d.is_object(a._id)&&(a=c.clone(a,1),a._id=a._id+""),a},_find:function(a,c){return this.table().mapSuccess(function(d){return b.funcCallback(d,d.find,a).mapSuccess(function(a){return c=c||{},"sort"in c&&(a=a.sort(c.sort)),"skip"in c&&(a=a.skip(c.skip)),"limit"in c&&(a=a.limit(c.limit)),b.funcCallback(a,a.toArray).mapSuccess(function(a){return new e(a)},this)},this)},this)},_count:function(a){return this.table().mapSuccess(function(c){return b.funcCallback(c,c.find,a).mapSuccess(function(a){return b.funcCallback(a,a.count)})})},_insertRow:function(a){return this.table().mapSuccess(function(c){return b.funcCallback(c,c.insert,a).mapSuccess(function(b){return a},this)},this)},_removeRow:function(a,c){return this.table().mapSuccess(function(c){return b.funcCallback(c,c.remove,a)},this)},_updateRow:function(a,c,d){return this.table().mapSuccess(function(d){return b.funcCallback(d,d.update,a,{$set:c}).mapSuccess(function(){return c})},this)},ensureIndex:function(a){({})[a]=1,this.table().success(function(b){b.ensureIndex(c.objectBy(a,1))})}})}),a.define("module:MongoDatabase",["data:Databases.Database","module:MongoDatabaseTable","base:Strings","base:Types","base:Objs","base:Promise","base:Net.Uri"],function(a,b,c,d,e,f,g,h){return a.extend({scoped:h},function(a){return{constructor:function(b){d.is_string(b)?(this.__dbUri=c.strip_start(b,"mongodb://"),this.__dbObject=this.cls.uriToObject(b)):(b=e.extend({database:"database",server:"localhost",port:27017},b),this.__dbObject=b,this.__dbUri=this.cls.objectToUri(b)),a.constructor.call(this),this.mongo_module=require("mongodb")},_tableClass:function(){return b},mongo_object_id:function(a){return this.mongo_module.ObjectID},mongodb:function(){if(this.__mongodb)return f.value(this.__mongodb);var a=f.create();return this.mongo_module.MongoClient.connect("mongodb://"+this.__dbUri,{server:{auto_reconnect:!0}},a.asyncCallbackFunc()),a.success(function(a){this.__mongodb=a},this)}}},{uriToObject:function(a){var b=g.parse(a);return{database:c.strip_start(b.path,"/"),server:b.host,port:b.port,username:b.user,password:b.password}},objectToUri:function(a){return a.path=a.database,g.build(a)}})})}).call(Scoped); |
@@ -12,3 +12,3 @@ module.exports = function(grunt) { | ||
.scopedclosurerevisionTask(null, "src/**/*.js", "dist/" + dist + "-noscoped.js", { | ||
"module": "global:BetaJS.Mongo", | ||
"module": "global:BetaJS.Data.Databases.Mongo", | ||
"base": "global:BetaJS", | ||
@@ -15,0 +15,0 @@ "data": "global:BetaJS.Data" |
{ | ||
"name": "betajs-mongodb", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "BetaJS-MongoDB is a MongoDB wrapper for BetaJS.", | ||
@@ -5,0 +5,0 @@ "contributors": ["Oliver Friedmann"], |
@@ -18,3 +18,3 @@ { | ||
"name": "betajs-mongodb", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "BetaJS-MongoDB is a MongoDB wrapper for BetaJS.", | ||
@@ -21,0 +21,0 @@ "contributors": [ |
@@ -1,2 +0,2 @@ | ||
# betajs-mongodb 1.0.0 | ||
# betajs-mongodb 1.0.1 | ||
[![Code Climate](https://codeclimate.com/github/betajs/betajs-mongodb/badges/gpa.svg)](https://codeclimate.com/github/betajs/betajs-mongodb) | ||
@@ -3,0 +3,0 @@ [![NPM](https://img.shields.io/npm/v/betajs-mongodb.svg?style=flat)](https://www.npmjs.com/package/betajs-mongodb) |
@@ -1,2 +0,2 @@ | ||
Scoped.define("module:Databases.MongoDatabaseTable", [ | ||
Scoped.define("module:MongoDatabaseTable", [ | ||
"data:Databases.DatabaseTable", | ||
@@ -3,0 +3,0 @@ "base:Promise", |
@@ -1,4 +0,4 @@ | ||
Scoped.define("module:Databases.MongoDatabase", [ | ||
Scoped.define("module:MongoDatabase", [ | ||
"data:Databases.Database", | ||
"module:Databases.MongoDatabaseTable", | ||
"module:MongoDatabaseTable", | ||
"base:Strings", | ||
@@ -5,0 +5,0 @@ "base:Types", |
@@ -7,3 +7,3 @@ test("mongo database store", function () { | ||
var db = new BetaJS.Mongo.Databases.MongoDatabase("mongodb://localhost/betajsmongodb"); | ||
var db = new BetaJS.Data.Databases.Mongo.MongoDatabase("mongodb://localhost/betajsmongodb"); | ||
db.getTable("tests").insertRow({x: 5}).success(function (object) { | ||
@@ -10,0 +10,0 @@ ok(!!object._id); |
@@ -7,3 +7,3 @@ test("mongo database store default id", function () { | ||
var mongodb = new BetaJS.Mongo.Databases.MongoDatabase("mongodb://localhost/betajsmongodb"); | ||
var mongodb = new BetaJS.Data.Databases.Mongo.MongoDatabase("mongodb://localhost/betajsmongodb"); | ||
var store = new BetaJS.Data.Stores.DatabaseStore(mongodb, "tests"); | ||
@@ -42,3 +42,3 @@ store.insert({x: 5}).success(function (object) { | ||
var mongodb = new BetaJS.Mongo.Databases.MongoDatabase("mongodb://localhost/betajsmongodb"); | ||
var mongodb = new BetaJS.Data.Databases.Mongo.MongoDatabase("mongodb://localhost/betajsmongodb"); | ||
var store = new BetaJS.Data.Stores.DatabaseStore(mongodb, "tests", "id", true); | ||
@@ -76,3 +76,3 @@ store.insert({x: 5, id: 1234}).success(function (object) { | ||
var mongodb = new BetaJS.Mongo.Databases.MongoDatabase("mongodb://localhost/betajsmongodb"); | ||
var mongodb = new BetaJS.Data.Databases.Mongo.MongoDatabase("mongodb://localhost/betajsmongodb"); | ||
var store = new BetaJS.Data.Stores.DatabaseStore(mongodb, "tests", "id"); | ||
@@ -79,0 +79,0 @@ store.insert({x: 5}).success(function (object) { |
Sorry, the diff of this file is not supported yet
97987