searchIndex callbacks

This commit is contained in:
barisusakli
2014-06-24 09:15:39 -04:00
parent aac2dd47af
commit e6d8e9c959
3 changed files with 13 additions and 12 deletions

View File

@@ -5,18 +5,19 @@ var winston = require('winston');
module.exports = function(db, module) {
var helpers = module.helpers.mongo;
module.searchIndex = function(key, content, id) {
module.searchIndex = function(key, content, id, callback) {
callback = callback || function() {};
var data = {
id:id,
key:key,
content:content
id: id,
key: key,
content: content
};
db.collection('search').update({id:id, key:key}, {$set:data}, {upsert:true, w: 1}, function(err, result) {
db.collection('search').update({id:id, key:key}, {$set:data}, {upsert:true, w: 1}, function(err) {
if(err) {
winston.error('Error indexing ' + err.message);
}
callback(err);
});
};