Reputation: 1110
I'm attempting to port a MySQL backed app to MongoDB with Mongoid. Some vital queries make use of MySQL's DateTime tools such as:
select * from posts where HOUR(posted) = 01
Where posted is a full DateTime timestamp. How can this be achieved using Mongoid?
Upvotes: 0
Views: 152
Reputation: 5294
MongoDB uses Javascript internally. You can send a piece of Javascript code as filter:
posts = Post.where("this.posted.getHours() == 1")
Upvotes: 1