mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +01:00 
			
		
		
		
	unread changes
This commit is contained in:
		| @@ -136,14 +136,18 @@ module.exports = function(db, module) { | ||||
| 	}; | ||||
|  | ||||
| 	module.getSortedSetRangeByScore = function(key, start, count, min, max, callback) { | ||||
| 		getSortedSetRangeByScore(key, start, count, min, max, 1, callback); | ||||
| 		getSortedSetRangeByScore(key, start, count, min, max, 1, false, callback); | ||||
| 	}; | ||||
|  | ||||
| 	module.getSortedSetRevRangeByScore = function(key, start, count, max, min, callback) { | ||||
| 		getSortedSetRangeByScore(key, start, count, min, max, -1, callback); | ||||
| 		getSortedSetRangeByScore(key, start, count, min, max, -1, false, callback); | ||||
| 	}; | ||||
|  | ||||
| 	function getSortedSetRangeByScore(key, start, count, min, max, sort, callback) { | ||||
| 	module.getSortedSetRevRangeByScoreWithScores = function(key, start, count, max, min, callback) { | ||||
| 		getSortedSetRangeByScore(key, start, count, min, max, -1, true, callback); | ||||
| 	}; | ||||
|  | ||||
| 	function getSortedSetRangeByScore(key, start, count, min, max, sort, withScores, callback) { | ||||
| 		if (!key) { | ||||
| 			return callback(); | ||||
| 		} | ||||
| @@ -159,7 +163,13 @@ module.exports = function(db, module) { | ||||
| 			scoreQuery['$lte'] = max; | ||||
| 		} | ||||
|  | ||||
| 		db.collection('objects').find({_key:key, score: scoreQuery}, {fields:{value:1}}) | ||||
| 		var fields = {_id: 0}; | ||||
| 		fields['value'] = 1; | ||||
| 		if (withScores) { | ||||
| 			fields['score'] = 1; | ||||
| 		} | ||||
|  | ||||
| 		db.collection('objects').find({_key:key, score: scoreQuery}, {fields: fields}) | ||||
| 			.limit(count) | ||||
| 			.skip(start) | ||||
| 			.sort({score: sort}) | ||||
| @@ -168,9 +178,11 @@ module.exports = function(db, module) { | ||||
| 					return callback(err); | ||||
| 				} | ||||
|  | ||||
| 				data = data.map(function(item) { | ||||
| 					return item.value; | ||||
| 				}); | ||||
| 				if (!withScores) { | ||||
| 					data = data.map(function(item) { | ||||
| 						return item.value; | ||||
| 					}); | ||||
| 				} | ||||
|  | ||||
| 				callback(err, data); | ||||
| 			}); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user