Support reverse sort for redis

This commit is contained in:
Anatoliy Chakkaev 2012-03-06 17:05:22 +04:00
parent 639820bf29
commit c33bc70756
2 changed files with 4 additions and 3 deletions

View File

@ -203,6 +203,7 @@ BridgeToRedis.prototype.all = function all(model, filter, callback) {
orders = [filter.order];
}
orders.forEach(function (key) {
key = key.split(' ')[0];
if (props[key].type.name !== 'Number' && props[key].type.name !== 'Date') {
allNumeric = false;
}
@ -246,7 +247,7 @@ BridgeToRedis.prototype.all = function all(model, filter, callback) {
orders.forEach(function (key) {
var m = key.match(/\s+(A|DE)SC$/i);
if (m) {
key = key.replace(/\s+DESC/i, '');
key = key.replace(/\s+(A|DE)SC/i, '');
if (m[1] === 'DE') reverse = true;
}
if (key !== 'id') {

View File

@ -52,8 +52,8 @@ function testOrm(schema) {
it('should define class', function (test) {
User = schema.define('User', {
name: String,
email: String,
name: { type: String, index: true },
email: { type: String, index: true },
bio: Text,
approved: Boolean,
joinedAt: Date,