PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Modifies a document in a collection of MongoDB database.
Example
let sFilter = "{ ""name"": ""Andy"" }"
let sModification = "{ ""$inc"": { ""score"": 1 } }"
let d = MongoModifyOne(Collection, sFilter, sModification)
// Finds the first contact whose "FirstName" member is set to "Jack" and modifies it to "Joey"

// Search filter
sFilter is string = "{ ""FirstName"": ""Jack"" }"

// Modification criterion
sModification is string = "{ ""$set"": {""FirstName"": ""Joey"" } }"

MongoModifyOne(gclCollection, sFilter, sModification)
Syntax
<Result> = MongoModifyOne(<Collection>, <Filter>, <Modification> [, <Sort>] [, <Options>])
<Result>: Variant
Document before or after modification (according to the selected option).
<Collection>: mongoCollection variable
Name of mongoCollection variable representing the collection of MongoDB database where the modification will be performed.
<Filter>: Type corresponding to the filter used
Description of filters in MongoDB format that will be applied to select the document to modify. This filter corresponds to:
  • a document in JSON format, in character string format.
  • a document in BSON format, in buffer format.
  • a variant.
<Modification>: Type corresponding to the format used
Description of modifications that will be made in the document corresponding to the filter. Corresponds to:
  • a document in JSON format, in character string format.
  • a document in BSON format, in buffer format.
  • a variant.
<Sort>: Optional type corresponding to the format used
Sort options used to define the first document that will be modified when several documents correspond to the filter. Corresponds to:
  • a document in JSON format, in character string format.
  • a document in BSON format, in buffer format.
  • a variant.
<Option>: Optional Integer constant
Modification options:
mongoAddIfNotFoundUsed to add the document if it does not exist in the collection.
mongoReturnValueAfterUsed to return the document after modification.
By default, if this constant is not used, the document returned corresponds to the document before modification.
Related Examples:
Native access to MongoDB Unit examples (WINDEV): Native access to MongoDB
[ + ] This example shows how to use the main functions of native access to MongoDB databases: adding data, reading (searching), modifying and deleting data in the database. The example also shows functions for saving files in the MongoDB GridFS data system.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230big.dll
Minimum required version
  • Version 22
This page is also available for…
Comments
Click [Add] to post a comment