Skip to main content

Home > git-documentdb > GitDocumentDB > put

GitDocumentDB.put() method#

Insert a JSON document if not exists. Otherwise, update it.

Signature:
put(_id: string | undefined | null, jsonDoc: JsonDoc, options?: PutOptions): Promise<PutResultJsonDoc>;

Parameters#

ParameterTypeDescription
_idstring | undefined | null_id is a file path whose extension is omitted.
jsonDocJsonDoc
optionsPutOptions
Returns:

Promise<PutResultJsonDoc >

Remarks#

  • The saved file path is ${GitDocumentDB#workingDir}/${_id}${extension} on the file system.

  • If _id is undefined, it is automatically generated.

  • _id property of a JsonDoc is automatically set or overwritten by _id parameter.

  • An update operation is not skipped even if no change occurred on a specified document.

  • This is an alias of GitDocumentDB#rootCollection.put()

Exceptions#

Err.InvalidJsonObjectError

Err.DatabaseClosingError

Err.TaskCancelError

# Errors from validateDocument, validateId

# Errors from putWorker