Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cqrsnode.dbstore

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cqrsnode.dbstore - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

37

lib/mongoose.js

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc