|
|
|
|
|
mongoOperationReplaceOne (Variable type) In french: mongoOpérationRemplacementUn
The mongoOperationReplaceOne type is used to define all the advanced characteristics of a document replace operation that will be added to a bulk operations list. The first document that matches the filter will be replaced. You can define and change the characteristics of this operation using different WLanguage properties. To be executed, this replacement operation will have to be added to the array of operations handled by MongoExecuteOperations. Note: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable. MongoCreateCollection(base,"col1",optCol)
col is mongoCollection = base..Collection["col1"]
MongoDeleteAll(col,"{}")
MongoAdd(col, "{""rub1"":""A"",""rub2"":1}")
MongoAdd(col, "{""rub1"":""a"",""rub2"":2}")
MongoAdd(col, "{""rub1"":3,""rub2"":1}")
MongoAdd(col, "{""rub1"":3,""rub2"":2}")
MongoAdd(col, "{""rub1"":4,""rub2"":1}")
MongoAdd(col, "{""rub1"":4,""rub2"":2}")
MongoAdd(col, "{""rub1"":5,""rub2"":1}")
MongoAdd(col, "{""rub1"":5,""rub2"":2}")
MongoAdd(col, "{""rub1"":6,""rub2"":1}")
t is array of mongoOperation dynamic
opAjout is mongoOperationAdd
opAjout.Document = "{""rub1"":1,""rub2"":1}"
t.Ajoute(opAjout)
opSupprimeOne is mongoOperationDeleteOne
opSupprimeOne.Filter = "{""rub1"":""a""}"
opSupprimeOne.Option = [
{
"collation":
{
"locale":"en_US",
"caseFirst": "lower"
}
}
]
t.Ajoute(opSupprimeOne)
opSupprimeTout is mongoOperationDeleteAll
opSupprimeTout.Filter = "{""rub1"":3}"
t.Ajoute(opSupprimeTout)
opModifieOne is mongoOperationUpdateOne
opModifieOne.Filter = "{""rub1"":4}"
opModifieOne.Update = "{ ""$inc"": {""rub2"":10}}"
t.Ajoute(opModifieOne)
opModifieTout is mongoOperationUpdateAll
opModifieTout.Filter = "{""rub1"":5}"
opModifieTout.Update = "{ ""$inc"": {""rub2"":20}}"
t.Ajoute(opModifieTout)
opRemplace is mongoOperationReplaceOne
opRemplace.Filter = "{""rub1"":6}"
opRemplace.Document = "{""rub1"":6,""rub2"":42}"
t.Ajoute(opRemplace)
let ret = MongoExecuteOperations(col, t)
opt is mongoOperationsOption
opt.Comment = "Ma belle opération"
opt.Ordered = False
optWrite is mongoWriteConcern
optWrite.Mode = mwcMajority
t.SupprimeTout()
opAjout.Document = "{""rub1"":10}"
t.Ajoute(opAjout)
ret = MongoExecuteOperations(col, t)
dbgAssert(ErrorOccurred = True)
opt.BypassDocumentValidation = True
ret = MongoExecuteOperations(col, t, opt, optWrite)
dbgAssert(ErrorOccurred = False)
Properties The following properties can be used to handle mongoOperationReplaceOne variables: | | | Property name | Type used | Effect |
---|
Filter | Type of filter used | Description of the MongoDB filter(s) that will be applied to select the document to replace. This filter corresponds to:- a JSON document, in string format.
- a BSON document, in buffer format.
- a variant.
| Document | Character string | Name of the document used to perform the replacement. | Option | Type of the format used | Replacement options. These options correspond to: - a JSON document, in string format.
- a BSON document, in buffer format.
- a variant.
For more details on these options, see the Mongo documentation. |
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|