Home > git-documentdb > Collection > insert
#
Collection.insert() methodInsert a JSON document
Signature:#
ParametersParameter | Type | Description |
---|---|---|
shortId | string | undefined | null | shortId is a file path whose collectionPath and extension are omitted. |
jsonDoc | JsonDoc | |
options | PutOptions |
Promise<PutResultJsonDoc >
#
RemarksThrows SameIdExistsError when a document that has the same _id exists. It might be better to use put() instead of insert().
The saved file path is
${GitDocumentDB#workingDir}/${Collection#collectionPath}/${shortId}${extension}
.If shortId is undefined, it is automatically generated.
_id property of a JsonDoc is automatically set or overwritten by shortId parameter.
#
Exceptions# Errors from validateDocument, validateId
# Errors from putWorker