Restheart mongodb filtering by date

我的未来我决定 提交于 2019-12-12 03:35:01

问题


I'm currently trying to get some json data from mongoDB database, and I use restHeart plugin for make my query.

I need to filter my answer with all result that the property "_lastupdated_on" is lower than the current date.

I tried something like that but doesn't work :

http://test:8081/purge/colPurge?filter={'_lastupdated_on':{'$eq':'2016-03-03T14:33:00Z'}}

Any idea ?

Version mongo 3.2 / restheart 1.1.6

Dorian


回答1:


The restheart system properties (those starting with _) are not stored in the db and cannot used for filtering and sorting.

You need to put a real date property in the documents to achieve what you need.

A tricky to automatically inject a "last update" field would be using a representation transformer (have a look at this discussion https://github.com/SoftInstigate/restheart/issues/95)



来源:https://stackoverflow.com/questions/35778707/restheart-mongodb-filtering-by-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!