Move index querying logic to /models

This commit is contained in:
lilia 2014-12-19 12:55:29 -08:00
parent 6cbde7894a
commit cfd4ccc803
3 changed files with 29 additions and 21 deletions

View file

@ -57,6 +57,22 @@
only: timestamp
}
});
},
fetchConversation: function(conversationId, options) {
options = options || {};
options.index = {
// 'conversation' index on [conversationId, received_at]
name : 'conversation',
lower : [conversationId],
upper : [conversationId, Number.MAX_VALUE],
order : 'desc'
// SELECT messages WHERE conversationId = this.id ORDER
// received_at DESC
};
// TODO pagination/infinite scroll
// limit: 10, offset: page*10,
return this.fetch(options);
}
});
})()