0
mongoDBコレクションの有効日付を現在の日付で更新しようとしています。有効期限がnullのコレクション内のすべてのドキュメントを更新したいとします。Muleでコレクション内のすべてのMongoドキュメントを一度に更新できますか?
これを行うにはどのようにトランスを構成しますか? Query ReferenceフィールドのinfoメッセージにはIdに関する情報が表示され、要素フィールドには、更新対象のドキュメントを置き換えるドキュメントが含まれているペイロードが必要なように見えます。私はちょうど1つのフィールドを更新しようとしていますが、現在はクエリでエラーが発生していますが、mongoDBコマンドラインでは動作します。
これは私が実装したい私のクエリです:ミュールでMongoのため
db.stores.update({"EffectiveEndDateTime" : null}, {$set : {"EffectiveEndDateTime" : "2017-01-13T18:56:55.257Z"}})
マイXMLの構成]を、これまで:私は取得しています
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:mongo="http://www.mulesoft.org/schema/mule/mongo" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:json="http://www.mulesoft.org/schema/mule/json"
xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
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.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
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/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.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">
<mongo:config name="Mongo_DB__Configuration" username="${mongodb.username}" password="${mongodb.password}" database="${mongodb.database}" host="${mongodb.host}" doc:name="Mongo DB: Configuration"/>
<flow name="deactivateCurrentDocumentsFlow">
<http:listener config-ref="httpListenerConfig" path="/mongo" allowedMethods="POST" doc:name="HTTP"/>
<mongo:update-documents-by-function config-ref="Mongo_DB__Configuration" collection="stores" function="$set : {"EffectiveEndDateTime": "2017-01-13T17:51:08.153Z" }" doc:name="Mongo DB"/>
<object-to-string-transformer doc:name="Object to String"/>
<logger level="INFO" doc:name="Logger"/>
</flow>
</mule>
がエラー:
Message : Failed to invoke updateDocumentsByFunction.
Payload : {NullPayload}
Payload Type : org.mule.transport.NullPayload
Element : /deactivateCurrentDocumentsFlow/processors/0 @ test --------------------------------------------------------------------------------
Root Exception stack trace:
com.mongodb.MongoWriteException: Unknown modifier: $set : {"EffectiveEndDateTime": "2017-01-13T17:51:08.153Z" }
ありがとう
私は上記の作業を行うことができませんでした。私は自分のコードを追加していますが、これまでいくつかのバリエーションを試しましたが、これまで運がありませんでした。私はどこが間違っているのか分かりますか?私はmongoDB 4.1コネクタ – user3165854
を使用しています。 'update-documents-by-function'は' update-documents-by-function'ではありません。それが役立つかどうかを見て、その間に私は見ていきます。 argsと同じです。 'function'から' functions'に変更する – Veeram
これで動作するように管理されています。 –
user3165854