CosmosDbEx.query

You're seeing just the function query, go back to CosmosDbEx module for more information.
Link to this function

query(container, query_text, params)

View Source

Specs

query(CosmosDbEx.Container.t(), String.t(), list()) ::
  {:ok
   | :bad_request
   | :conflict
   | :entity_too_large
   | :not_found
   | :storage_limit_reached
   | :unauthorized, CosmosDbEx.Response.t()}

Sends a query to Cosmos Db.

Parameters

  • query: The query contains the SQL query text.
  • params: A List of key/value pairs that correspond to values in the query.

Query String and Params

Notice the query string in the example below. For each value that will be substituted by an entry in the params list, the key in the query string must be annotated with an '@' symbol.

Example:

iex> query_text = "SELECT * FROM ItemsContainer c WHERE c.id = @id and c.name = @name"
iex> params = [{"id", "ACME-HD-WOLF01234"}, {"name", "ACME hair dryer"}]
iex> CosmosDbEx.query(query_text, params)
{:ok,
 %CosmosDbEx.Response{
   body: %{
     "Documents" => [
       %{
         "_attachments" => "attachments/",
         "_etag" => ""8203015f-0000-0200-0000-60a1c47e0000"",
         "_rid" => "AAarArAAAAAFAAAAAAAAAA==",
         "_ts" => 1621214334,
         "id" => "ACME-HD-WOLF01234",
         "location" => "Bottom of a cliff",
         "name" => "ACME hair dryer"
       }
     ]
   },
   count: 1,
   properties: %{
     continuation_token: nil,
     request_charge: "2.83",
     request_duration: "0.734"
   },
   resource_id: "AA8rAA2AN48="
 }
}