◷ Reading Time: 3 minutes
cosmosCreate
Creates a document in your collection.
cosmosCreate (connection, payload, partitionKey)
- connection: connection string to the Cosmos DB collection.
- endpoint: Address to the service endpoint
- masterKey: Master/Primary key value from cosmosDB
- database: Name of the database on the cosmosDB service
- collection: Name of the collection to target
- retry.attempts: numbers of attempts for retry. Default is 1.
- retry.delay: milliseconds between each attempt. Default is 1.
- retry.delayGrowth: exponential value to increase the delay between each retry. Default is 1.
- payload: json content of the document to be created.
- partitionKey: key to filter partitions in the collection.
cosmosQuery
Runs a SQL query against the documents in your collection.
documents |cosmosQuery (connection, query, partitionKey)
- connection: connection string to the Cosmos DB collection.
- endpoint: Address to the service endpoint
- masterKey: Master/Primary key value from cosmosDB
- database: Name of the database on the cosmosDB service
- collection: Name of the collection to target
- retry.attempts: numbers of attempts for retry. Default is 1.
- retry.delay: milliseconds between each attempt. Default is 1.
- retry.delayGrowth: exponential value to increase the delay between each retry. Default is 1.
- query:
- Cosmos DB compatible SQL string query.
- An object representing the statement structure as below
- for stored procedure execution {sp: string, inputs: array}
When there are no inputs needed,inputs
should not be provided. - for query execution {query:string}
- for stored procedure execution {sp: string, inputs: array}
- partitionKey: key to filter partitions in the collection. When this parameter is not provided, the query will be considered as a cross-partition query.
Examples:
In the below examples, cnn
is a parameter that holds the connection string.
Example 1: Querying consmosDB with a plain query statement:
documents |cosmosQuery(cnn, 'SELECT * FROM root')
Example 2: Executing a stored procedure on consmosDB with input values:
documents |cosmosQuery(cnn,
{
sp:'customers_invoice_report',
inputs:[24,679,1030]
}
)
cosmosUpdate
Updates a document in your collection.
cosmosCreate (connection, payload, documentId, partitionKey)
- connection: connection string to the Cosmos DB collection.
- endpoint: Address to the service endpoint
- masterKey: Master/Primary key value from cosmosDB
- database: Name of the database on the cosmosDB service
- collection: Name of the collection to target
- retry.attempts: numbers of attempts for retry. Default is 1.
- retry.delay: milliseconds between each attempt. Default is 1.
- retry.delayGrowth: exponential value to increase the delay between each retry. Default is 1.
- payload: json content of the document to be updated..
- documentId: Identifier of the document to be updated.
- partitionKey: key to filter partitions in the collection.
cosmosDelete
Deletes a document in your collection.
cosmosDelete (connection, documentId, partitionKey)
- connection: connection string to the Cosmos DB collection.
- endpoint: Address to the service endpoint
- masterKey: Master/Primary key value from cosmosDB
- database: Name of the database on the cosmosDB service
- collection: Name of the collection to target
- retry.attempts: numbers of attempts for retry. Default is 1.
- retry.delay: milliseconds between each attempt. Default is 1.
- retry.delayGrowth: exponential value to increase the delay between each retry. Default is 1.
- documentId: Identifier of the document to be deleted.
- partitionKey: key to filter partitions in the collection.