mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
searchIndex callbacks
This commit is contained in:
@@ -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
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user