This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new ed87605 camel-mongodb documentation changed (#6092) ed87605 is described below commit ed8760555db52137486615b04e0a3e3157eaa352 Author: Vladimir V. Bychkov <m...@bychkov.name> AuthorDate: Wed Sep 15 06:38:52 2021 +0200 camel-mongodb documentation changed (#6092) Co-authored-by: Vladimir V. Bychkov <v.bych...@betterbits.de> --- .../camel-mongodb/src/main/docs/mongodb-component.adoc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/components/camel-mongodb/src/main/docs/mongodb-component.adoc b/components/camel-mongodb/src/main/docs/mongodb-component.adoc index 4631a3f..c71e7e6 100644 --- a/components/camel-mongodb/src/main/docs/mongodb-component.adoc +++ b/components/camel-mongodb/src/main/docs/mongodb-component.adoc @@ -557,6 +557,14 @@ from("direct:insert") .to("mongodb:myDb?database=flights&collection=tickets&operation=save"); --------------------------------------------------------------------------- +[source,java] +------------------------------------------------------------------------------------------------------------------------------------------ +// route: from("direct:insert").to("mongodb:myDb?database=flights&collection=tickets&operation=save"); +org.bson.Document docForSave = new org.bson.Document(); +docForSave.put("key", "value"); +Object result = template.requestBody("direct:insert", docForSave); +------------------------------------------------------------------------------------------------------------------------------------------ + ==== update Update one or multiple records on the collection. Requires a filter query and @@ -620,9 +628,12 @@ field equals true by setting the value of the "scientist" field to [source,java] ------------------------------------------------------------------------------------------------------------------------------------------ // route: from("direct:update").to("mongodb:myDb?database=science&collection=notableScientists&operation=update"); +List<Bson> body = new ArrayList<>(); Bson filterField = Filters.eq("filterField", true); -String updateObj = Updates.set("scientist", "Darwin"); -Object result = template.requestBodyAndHeader("direct:update", new Bson[] {filterField, Document.parse(updateObj)}, MongoDbConstants.MULTIUPDATE, true); +body.add(filterField); +BsonDocument updateObj = new BsonDocument().append("$set", new BsonDocument("scientist", new BsonString("Darwin"))); +body.add(updateObj); +Object result = template.requestBodyAndHeader("direct:update", body, MongoDbConstants.MULTIUPDATE, true); ------------------------------------------------------------------------------------------------------------------------------------------ [source,java]