mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
searchIndex callbacks
This commit is contained in:
@@ -6,7 +6,7 @@ var nconf = require('nconf'),
|
|||||||
module.exports = function(db, module) {
|
module.exports = function(db, module) {
|
||||||
var helpers = module.helpers.level;
|
var helpers = module.helpers.level;
|
||||||
|
|
||||||
module.searchIndex = function(key, content, id) {
|
module.searchIndex = function(key, content, id, callback) {
|
||||||
// o.O
|
// o.O
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,18 +5,19 @@ var winston = require('winston');
|
|||||||
module.exports = function(db, module) {
|
module.exports = function(db, module) {
|
||||||
var helpers = module.helpers.mongo;
|
var helpers = module.helpers.mongo;
|
||||||
|
|
||||||
|
module.searchIndex = function(key, content, id, callback) {
|
||||||
module.searchIndex = function(key, content, id) {
|
callback = callback || function() {};
|
||||||
var data = {
|
var data = {
|
||||||
id:id,
|
id: id,
|
||||||
key:key,
|
key: key,
|
||||||
content:content
|
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) {
|
if(err) {
|
||||||
winston.error('Error indexing ' + err.message);
|
winston.error('Error indexing ' + err.message);
|
||||||
}
|
}
|
||||||
|
callback(err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
module.exports = function(redisClient, module) {
|
module.exports = function(redisClient, module) {
|
||||||
module.searchIndex = function(key, content, id) {
|
module.searchIndex = function(key, content, id, callback) {
|
||||||
if (key === 'post') {
|
if (key === 'post') {
|
||||||
module.postSearch.index(content, id);
|
module.postSearch.index(content, id, callback);
|
||||||
} else if(key === 'topic') {
|
} else if(key === 'topic') {
|
||||||
module.topicSearch.index(content, id);
|
module.topicSearch.index(content, id, callback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user