cqrsnode.dbstore
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -5,36 +5,33 @@ var mongoose = require('mongoose'), | ||
var db = mongoose.createConnection('localhost','cqrsnodedb'); | ||
module.exports = Mongo; | ||
function Mongo(name,fields){ | ||
function Mongo(cfg){ | ||
var sc = {} | ||
var models = {} | ||
fields.forEach(function(f){ | ||
sc[f] = {} | ||
}) | ||
var db = mongoose.createConnection(cfg.url,cfg.dbname); | ||
var schema = new Schema(sc); | ||
var Model = db.model(name,schema); | ||
var schemas = cfg.schemas; | ||
for(var k in schemas){ | ||
if(schemas.hasOwnProperty(k)){ | ||
models[k] = db.model(k,mongoose.Schema(schemas[k])); | ||
} | ||
} | ||
// the extensions is a Model, see http://www.mongoosejs.com | ||
this.extensions = Model; | ||
this.name = name; | ||
this.remove = function(id,callback){ | ||
Model.remove({id:id},callback); | ||
this.remove = function(AggreName,id,callback){ | ||
models[AggreName].remove({id:id},callback); | ||
} | ||
this.save = function(data,callback){ | ||
var o = new Model(data); | ||
this.save = function(AggreName,data,callback){ | ||
var o = new models[AggreName](data); | ||
o.save(callback); | ||
} | ||
this.update = function(id,data,callback){ | ||
Model.update({id:id},data,callback); | ||
this.update = function(AggreName,id,data,callback){ | ||
models[AggreName].update({id:id},data,callback); | ||
} | ||
this.find = function(){ | ||
this.find = function(AggreName){ | ||
@@ -41,0 +38,0 @@ } |
{ | ||
"name": "cqrsnode.dbstore", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "db store for cqrsnode", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2307
51