Skip to content

Commit

Permalink
#37 Adding update() & remove() methods
Browse files Browse the repository at this point in the history
  • Loading branch information
tracend committed Jan 12, 2013
1 parent 58f8693 commit a9617ef
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions lib/crudr.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,65 @@ CRUDr.prototype = {
// include dbs / backends
add: function ( options ) {

//console.log( "----- add ------");

var db = options.db || false;
var backends = options.backends || false;
// stop if there's no db or backend
if( !db || !backends ) return;
// create new backends
var backends = this.backends( options );
// extend the existing db object
this.db = _.extend( this.db, backends);
// update routes
//console.log( backends );
// update sockets
this.sockets.events( backends );
this.sockets.db = this.db;

},
// update an existing backend
update : function( options ){

console.log( "----- update ------");

var db = options.db || false;
var backends = options.backends || false;
// stop if there's no db or backend
if( !db || !backends ) return;
// create new backends
var backends = this.backends( options );
// extend the existing db object
//console.log( backends );
this.db = _.extend( this.db, backends);
// update routes
//console.log( backends );
// update sockets
this.sockets.events( backends );
this.sockets.db = this.db;

},
// remove a backend
remove: function ( options ) {

//console.log( "----- remove ------");

var db = options.db || false;
var backends = options.backends || false;
// stop if there's no db or backend
if( !db || !backends ) return;
// create new backends
var backends = this.backends( options );

for( var i in backends ){
delete this.db[i];
}
// remove events from sockets


//update dbs
this.sockets.db = this.db;

}


Expand Down

0 comments on commit a9617ef

Please sign in to comment.