Restheart MongoDB按日期过滤 [英] Restheart mongodb filtering by date

查看:65
本文介绍了Restheart MongoDB按日期过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试从mongoDB数据库中获取一些json数据,并且我使用restHeart插件进行查询.

我需要使用所有结果来过滤我的答案,该结果是"_lastupdated_on"属性低于当前日期.

我尝试了类似的方法,但是没有用:

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

有什么主意吗?

版本mongo 3.2/restheart 1.1.6

多利安(Dorian)

解决方案

restheart系统属性(以_开头的属性)未存储在db中,并且不能用于过滤和排序.

您需要在文档中放置一个实际的日期属性才能实现所需的功能.

自动注入最新更新"字段的技巧很棘手,那就是使用表示形式转换器(请看以下讨论 https://github.com/SoftInstigate/restheart/issues/95 )

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

解决方案

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)

这篇关于Restheart MongoDB按日期过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆