Skip to main content

Home > git-documentdb > Collection > put

Collection.put() method#

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

Signature:
put(jsonDoc: JsonDoc, options?: PutOptions): Promise<PutResultJsonDoc>;

Parameters#

ParameterTypeDescription
jsonDocJsonDocJsonDoc whose _id is shortId. shortId is a file path whose collectionPath and extension are omitted.
optionsPutOptions
Returns:

Promise<PutResultJsonDoc >

Remarks#

  • The saved file path is ${GitDocumentDB#workingDir}/${Collection#collectionPath}${jsonDoc._id}${extension} .

  • If _id is undefined, it is automatically generated.

Exceptions#

Err.InvalidJsonObjectError

Err.DatabaseClosingError

Err.TaskCancelError

# Errors from validateDocument, validateId

# Errors from putWorker