searchIndex callbacks

v1.18.x
barisusakli 11 years ago
parent aac2dd47af
commit e6d8e9c959

@ -6,7 +6,7 @@ var nconf = require('nconf'),
module.exports = function(db, module) {
var helpers = module.helpers.level;
module.searchIndex = function(key, content, id) {
module.searchIndex = function(key, content, id, callback) {
// o.O
};

@ -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
};
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);
});
};

@ -1,11 +1,11 @@
"use strict";
module.exports = function(redisClient, module) {
module.searchIndex = function(key, content, id) {
module.searchIndex = function(key, content, id, callback) {
if (key === 'post') {
module.postSearch.index(content, id);
module.postSearch.index(content, id, callback);
} else if(key === 'topic') {
module.topicSearch.index(content, id);
module.topicSearch.index(content, id, callback);
}
};

Loading…
Cancel
Save