Ideas:
1, concurrent multi-link
2, single link
The concurrency is not said, directly more than a few db just fine. A single link needs to use callback recursion. Mark down
var Db = require (' MongoDB ').
Db; var Server = require (' MongoDB ').
Server; var md5db = {//database config _dbconf: {dbName: ' comment ',//database name ServerIP: ' xxxxxx ',//database access Ip,fedev machine IP serverport: XXXX//mongodb Access Port}, Init:function () {}, itemindex:0, Updatefilesmodified:function (objarray,callback) {var dbCon
f = this._dbconf;
var = this;
var db = new db (Dbconf.dbname, New Server (Dbconf.serverip, Dbconf.serverport), {safe:true});
Db.open (err, db) {var list = Db.collection (' files ');
Self.updateinstance (list, objarray,db);
});
}, Updateinstance:function (list,items,db) {var = this; List.update ({Fileid:items[self.itemindex]}, {$inc: {modified:1}}, {upsert:true, w:1}, function (E
RR, Item) {if (err) console.log (err.stack);
self.itemindex++;
if (Self.itemindex >= items.length) {db.close ();
Self.itemindex = 0;
}else{self.updateinstance (LIST,ITEMS,DB)} });
}
}; Module.exports = md5db;