开发者

Finding all items before a certain item in mongomapper

开发者 https://www.devze.com 2023-02-20 10:41 出处:网络
I want to find all items before a certain item in mongomapper. For example if I have five User classes saved and I pass in the ID of user 3 then I expect to get back the first two items.

I want to find all items before a certain item in mongomapper.

For example if I have five User classes saved and I pass in the ID of user 3 then I expect to get back the first two items.

Any开发者_高级运维 ideas how to do this efficiently?


The ObjectID key in Mongo is comprised of a few things, one of them being a timestamp. You can probably use that as a condition on which to query. Look here for more details, http://mongotips.com/b/a-few-objectid-tricks/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号