Home > git-documentdb > GitDocumentDB > insert
GitDocumentDB.insert() method#
Insert a JSON document
Signature:Parameters#
| Parameter | Type | Description |
|---|---|---|
| jsonDoc | JsonDoc | JsonDoc whose _id is shortId. shortId is a file path whose collectionPath and extension are omitted. |
| options | PutOptions |
Promise<PutResultJsonDoc >
Remarks#
Throws SameIdExistsError when a document that has the same _id exists. It might be better to use put() instead of insert().
If _id is undefined, it is automatically generated.
The saved file path is
${GitDocumentDB#workingDir}/${jsonDoc._id}${extension}on the file system.This is an alias of GitDocumentDB#rootCollection.insert()
Exceptions#
# Errors from validateDocument, validateId
# Errors from putWorker