searchIndex callbacks

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

@ -6,12 +6,12 @@ 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
};
module.search = function(key, term, limit, callback) {
// O.o
// O.o
};
module.searchRemove = function(key, id, callback) {
@ -22,7 +22,7 @@ module.exports = function(db, module) {
db.close(function() {
module.leveldown.destroy(nconf.get('level:database'), function() {
db.open(callback);
});
});
});
};

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

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