mongodb - Mule Mongo query on date range -
from mongo able retrieve documents since specific time using example such as: db.getcollection('events').find({ whenoccurred: {$gte: new date(isodate().gettime() - 1000 * 60 * 60 * 24 * 120) }})
however mule, unable find way construct dw field use $gte operator on date field.
any ideas?
you can result using query java driver using org.bson.document check this more details on that. need use java component this. in observation can not directly use $gte date value in monodb query. following have tried not return result.
<?xml version="1.0" encoding="utf-8"?> <mule xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:mongo="http://www.mulesoft.org/schema/mule/mongo" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/mongo http://www.mulesoft.org/schema/mule/mongo/current/mule-mongo.xsd http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd"> <http:listener-config name="http_listener_configuration" host="0.0.0.0" port="8081" doc:name="http listener configuration"/> <mongo:config name="mongo_db" username="mmcuser" password="mmcmongo" database="testdb" doc:name="mongo db"/> <flow name="mongodb-testflow"> <http:listener config-ref="http_listener_configuration" path="/mongodq" doc:name="http"/> <set-payload value="#[string:{"from":{"$gte":"2016-04-07t05:30:00.000z"}}]" doc:name="set payload"/> <json:object-to-json-transformer doc:name="object json"/> <mongo:json-to-dbobject doc:name="mongo db"/> <mongo:find-objects config-ref="mongo_db" collection="appointment" query-ref="#[payload]" doc:name="mongo db"/> <logger level="info" doc:name="logger"/> </flow> </mule>
Comments
Post a Comment