Documentation ¶
Index ¶
- Constants
- type CallOption
- func ChangeFeed() CallOption
- func ConsistencyLevel(consistency Consistency) CallOption
- func Continuation(continuation string) CallOption
- func CrossPartition() CallOption
- func EnableParallelizeCrossPartitionQuery() CallOption
- func EnablePopulateQueryMetrics() CallOption
- func EnableQueryScan() CallOption
- func IfMatch(eTag string) CallOption
- func IfModifiedSince(date string) CallOption
- func IfNoneMatch(eTag string) CallOption
- func Limit(limit int) CallOption
- func PartitionKey(partitionKey interface{}) CallOption
- func PartitionKeyRangeID(id int) CallOption
- func QueryVersion() CallOption
- func SessionToken(sessionToken string) CallOption
- func ThroughputRUs(rus int) CallOption
- func Upsert() CallOption
- func WithContext(ctx context.Context) CallOption
- type Collection
- type Config
- type Consistency
- type CosmosDB
- func (c *CosmosDB) CreateCollection(db string, body interface{}, opts ...CallOption) (coll *Collection, err error)
- func (c *CosmosDB) CreateDatabase(body interface{}, opts ...CallOption) (db *Database, err error)
- func (c *CosmosDB) CreateDocument(coll string, doc interface{}, opts ...CallOption) (*Response, error)
- func (c *CosmosDB) CreateStoredProcedure(coll string, body interface{}, opts ...CallOption) (sproc *Sproc, err error)
- func (c *CosmosDB) CreateUserDefinedFunction(coll string, body interface{}, opts ...CallOption) (udf *UDF, err error)
- func (c *CosmosDB) DeleteCollection(link string) (*Response, error)
- func (c *CosmosDB) DeleteDatabase(link string) (*Response, error)
- func (c *CosmosDB) DeleteDocument(link string, opts ...CallOption) (*Response, error)
- func (c *CosmosDB) DeleteStoredProcedure(link string) (*Response, error)
- func (c *CosmosDB) DeleteUserDefinedFunction(link string) (*Response, error)
- func (c *CosmosDB) DisableDebug()
- func (c *CosmosDB) EnableDebug()
- func (c *CosmosDB) ExecuteStoredProcedure(link string, params, body interface{}, opts ...CallOption) (resp *Response, err error)
- func (c *CosmosDB) GetConfig() Config
- func (c *CosmosDB) GetURI() string
- func (c *CosmosDB) NewPagableQuery(coll string, query *QueryWithParameters, limit int, docs interface{}, ...) *PagableQuery
- func (c *CosmosDB) QueryCollections(db, query string, opts ...CallOption) (colls []Collection, err error)
- func (c *CosmosDB) QueryDatabases(query string, opts ...CallOption) (dbs []Database, err error)
- func (c *CosmosDB) QueryDocuments(coll, query string, docs interface{}, opts ...CallOption) (resp *Response, err error)
- func (c *CosmosDB) QueryDocumentsWithParameters(coll string, query *QueryWithParameters, docs interface{}, opts ...CallOption) (resp *Response, err error)
- func (c *CosmosDB) QueryPartitionKeyRanges(coll string, query string, opts ...CallOption) (ranges []PartitionKeyRange, err error)
- func (c *CosmosDB) QueryStoredProcedures(coll, query string, opts ...CallOption) (sprocs []Sproc, err error)
- func (c *CosmosDB) QueryUserDefinedFunctions(coll, query string, opts ...CallOption) (udfs []UDF, err error)
- func (c *CosmosDB) ReadCollection(link string, opts ...CallOption) (coll *Collection, err error)
- func (c *CosmosDB) ReadCollections(db string, opts ...CallOption) (colls []Collection, err error)
- func (c *CosmosDB) ReadDatabase(link string, opts ...CallOption) (db *Database, err error)
- func (c *CosmosDB) ReadDatabases(opts ...CallOption) (dbs []Database, err error)
- func (c *CosmosDB) ReadDocument(link string, doc interface{}, opts ...CallOption) (resp *Response, err error)
- func (c *CosmosDB) ReadDocuments(coll string, docs interface{}, opts ...CallOption) (*Response, error)
- func (c *CosmosDB) ReadStoredProcedure(link string, opts ...CallOption) (sproc *Sproc, err error)
- func (c *CosmosDB) ReadStoredProcedures(coll string, opts ...CallOption) (sprocs []Sproc, err error)
- func (c *CosmosDB) ReadUserDefinedFunction(link string, opts ...CallOption) (udf *UDF, err error)
- func (c *CosmosDB) ReadUserDefinedFunctions(coll string, opts ...CallOption) (udfs []UDF, err error)
- func (c *CosmosDB) ReplaceDatabase(link string, body interface{}, opts ...CallOption) (db *Database, err error)
- func (c *CosmosDB) ReplaceDocument(link string, doc interface{}, opts ...CallOption) (*Response, error)
- func (c *CosmosDB) ReplaceDocumentAsync(link string, doc interface{}, opts ...CallOption) (*Response, error)
- func (c *CosmosDB) ReplaceStoredProcedure(link string, body interface{}, opts ...CallOption) (sproc *Sproc, err error)
- func (c *CosmosDB) ReplaceUserDefinedFunction(link string, body interface{}, opts ...CallOption) (udf *UDF, err error)
- func (c *CosmosDB) UpsertDocument(coll string, doc interface{}, opts ...CallOption) (*Response, error)
- type Database
- type Document
- type Expirable
- type IndexingPolicy
- type Metrics
- type PagableQuery
- type PartitionKeyDef
- type PartitionKeyRange
- type QueryParameter
- type QueryWithParameters
- type Request
- type RequestError
- type Resource
- type Response
- type Sproc
- type UDF
Constants ¶
const ( // HeaderActivityID - A client supplied identifier for the operation, which is echoed in the server response. // The recommended value is a unique identifier. HeaderActivityID = "X-Ms-Activity-Id" // HeaderAIM - Indicates a change feed request. Must be set to "Incremental feed", or omitted otherwise. HeaderAIM = "A-IM" //HeaderAllowTenativeWrites - For using multiple write locations. HeaderAllowTenativeWrites = "X-Ms-Cosmos-Allow-Tentative-Writes" // HeaderAuth - The authorization token for the request HeaderAuth = "Authorization" // HeaderConsistencyLevel - The consistency level override for read options against documents and attachments. // The valid values are: Strong, Bounded, Session, or Eventual HeaderConsistencyLevel = "X-Ms-Consistency-Level" // HeaderContentLength - Indicates the size of the entity-body, in bytes, sent to the recipient. HeaderContentLength = "Content-Length" // HeaderContentType - POST it must be application/query+json // attachments must be set to the Mime type of the attachment // all other tasks must be application/json HeaderContentType = "Content-Type" // HeaderContinuation - A string token returned for queries and read-feed operations if there are more // results to be read. Clients can retrieve the next page of results by resubmitting the request with this value. HeaderContinuation = "X-Ms-Continuation" // HeaderCrossPartition - When this header is set to true and if your query doesn't have a partition key, Azure // Cosmos DB fans out the query across partitions. The fan out is done by issuing individual queries to all the // partitions. To read the query results, the client applications should consume the results from the FeedResponse // and check for the ContinuationToken property. To read all the results, keep iterating on the data until the // ContinuationToken is null. HeaderCrossPartition = "X-Ms-Documentdb-Query-Enablecrosspartition" // HeaderEnableScan - Use an index scan to process the query if the right index path of type is not available. HeaderEnableScan = "X-Ms-Documentdb-Query-Enable-Scan" // HeaderIfMatch - Used to make operation conditional for optimistic concurrency. // The value should be the etag value of the resource. HeaderIfMatch = "If-Match" // HeaderIfModifiedSince - Returns etag of resource modified after specified date in RFC 1123 format. // Ignored when If-None-Match is specified HeaderIfModifiedSince = "If-Modified-Since" // HeaderIfNonMatch - Makes operation conditional to only execute if the resource has changed. // The value should be the etag of the resource. HeaderIfNonMatch = "If-None-Match" // HeaderIndexingDirective - Overide the collections default indexing policy, set to Include or Exclude. HeaderIndexingDirective = "x-ms-indexing-directive" // HeaderIsQuery - Required for queries. This property must be set to true. HeaderIsQuery = "X-Ms-Documentdb-Isquery" // HeaderIsQueryPlan - HeaderIsQueryPlan = "X-Ms-Cosmos-Is-Query-Plan-Request" // HeaderMaxItemCount - An integer indicating the maximum number of items to be returned per page. // An x-ms-max-item-count of -1 can be specified to let the service determine the optimal item count. HeaderMaxItemCount = "X-Ms-Max-Item-Count" // HeaderOfferThroughput - The user specified throughput for the collection expressed in units of 100 // request units per second. HeaderOfferThroughput = "X-Ms-Offer-Throughput" // HeaderParalelizeCrossPartition - Sets the query to run in parallel across partitions. HeaderParalelizeCrossPartition = "X-Ms-Documentdb-Query-Parallelizecrosspartitionquery" // HeaderPartitionKey - The partition key value for the requested document or attachment operation. // Required for operations against documents and attachments when the collection definition includes // a partition key definition. This value is used to scope your query to documents that match the partition // key criteria. By design it's a single partition query. Supported in API versions 2015-12-16 and newer. // Currently, the SQL API supports a single partition key, so this is an array containing just one value. HeaderPartitionKey = "X-Ms-Documentdb-Partitionkey" // HeaderPartitionKeyRangeID - Used in change feed requests. The partition key range ID for reading data. HeaderPartitionKeyRangeID = "X-Ms-Documentdb-Partitionkeyrangeid" // HeaderPopulateQueryMetrics - Set to obtain detailed metrics on query execution. HeaderPopulateQueryMetrics = "X-Ms-Documentdb-Populatequerymetrics" // HeaderQueryMetrics - The query statistics for the execution. This is a delimited string containing statistics // of time spent in the various phases of query execution. HeaderQueryMetrics = "X-Ms-Documentdb-Query-Metrics" // HeaderQueryVersion - Set the query version. HeaderQueryVersion = "X-Ms-Cosmos-Query-Version" // HeaderRequestCharge - The number of request units consumed by the operation. HeaderRequestCharge = "X-Ms-Request-Charge" // HeaderSessionToken - A string token used with session level consistency. HeaderSessionToken = "X-Ms-Session-Token" // HeaderSupportedQueryFeatures - HeaderSupportedQueryFeatures = "X-Ms-Cosmos-Supported-Query-Features" // HeaderUpsert - If set to true, Cosmos DB creates the document with the ID (and partition key value if applicable) // if it doesn’t exist, or update the document if it exists. HeaderUpsert = "X-Ms-Documentdb-Is-Upsert" // HeaderUserAgent - A string that specifies the client user agent performing the request. // The recommended format is {user agent name}/{version}. HeaderUserAgent = "User-Agent" // HeaderVersion - The version of the Cosmos DB REST service. HeaderVersion = "X-Ms-Version" // HeaderXDate - The date of the request per RFC 1123 date format expressed in Coordinated Universal Time. // For example, Fri, 08 Apr 2015 03:52:31 GMT. HeaderXDate = "X-Ms-Date" )
const ( // SupportedQueryVersion - The current query version supported. SupportedQueryVersion = "1.4" // SupportedVersion - The current supported API version. SupportedAPIVersion = "2018-12-31" SupportedAPIVersionNoPartition = "2017-02-22" // UserAgent - The current version of gocosmosdb. UserAgent = "gocosmosdb/1.0" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallOption ¶
CallOption function
func ConsistencyLevel ¶
func ConsistencyLevel(consistency Consistency) CallOption
ConsistencyLevel - override for read options against documents and attachments. The valid values are: Strong, Bounded, Session, or Eventual (in order of strongest to weakest). The override must be the same or weaker than the account�s configured consistency level.
func Continuation ¶
func Continuation(continuation string) CallOption
Continuation - a string token returned for queries and read-feed operations if there are more results to be read. Clients can retrieve the next page of results by resubmitting the request with the x-ms-continuation request header set to this value.
func CrossPartition ¶
func CrossPartition() CallOption
CrossPartition - allows query to run on all partitions
func EnableParallelizeCrossPartitionQuery ¶
func EnableParallelizeCrossPartitionQuery() CallOption
EnableParallelizeCrossPartitionQuery - add the parallelize header
func EnablePopulateQueryMetrics ¶
func EnablePopulateQueryMetrics() CallOption
EnablePopulateQueryMetrics - add the parallelize header
func IfMatch ¶
func IfMatch(eTag string) CallOption
IfMatch - used to make operation conditional for optimistic concurrency. The value should be the etag value of the resource. (applicable only on PUT and DELETE)
func IfModifiedSince ¶
func IfModifiedSince(date string) CallOption
IfModifiedSince - returns etag of resource modified after specified date in RFC 1123 format. Ignored when If-None-Match is specified Optional (applicable only on GET)
func IfNoneMatch ¶
func IfNoneMatch(eTag string) CallOption
IfNoneMatch - makes operation conditional to only execute if the resource has changed. The value should be the etag of the resource. Optional (applicable only on GET)
func PartitionKey ¶
func PartitionKey(partitionKey interface{}) CallOption
PartitionKey - specificy which partiotion will be used to satisfty the request
func PartitionKeyRangeID ¶
func PartitionKeyRangeID(id int) CallOption
PartitionKeyRangeID - adds the partition key range header
func QueryVersion ¶
func QueryVersion() CallOption
QueryVersion - add the query latest query version header
func SessionToken ¶
func SessionToken(sessionToken string) CallOption
SessionToken - a string token used with session level consistency.
func ThroughputRUs ¶
func ThroughputRUs(rus int) CallOption
ThroughputRUs - adds throughput headers for container creation
func Upsert ¶
func Upsert() CallOption
Upsert - if set to true, Cosmos DB creates the document with the ID (and partition key value if applicable) if it doesn’t exist, or update the document if it exists.
func WithContext ¶
func WithContext(ctx context.Context) CallOption
WithContext - adds a context to the request
type Collection ¶
type Collection struct { Resource IndexingPolicy IndexingPolicy `json:"indexingPolicy,omitempty"` PartitionKeyDef PartitionKeyDef `json:"partitionKey,omitempty"` Docs string `json:"_docs,omitempty"` Udf string `json:"_udfs,omitempty"` Sporcs string `json:"_sporcs,omitempty"` Triggers string `json:"_triggers,omitempty"` Conflicts string `json:"_conflicts,omitempty"` }
Collection
type Config ¶
type Config struct { MasterKey string Debug bool Verbose bool PartitionKeyStructField string // eg. "Id" PartitionKeyPath string // slash denoted path eg. "/id" RetryWaitMin time.Duration RetryWaitMax time.Duration RetryMax int Pooled bool }
Config - Stores configuration for the gocosmosdb client
type Consistency ¶
type Consistency string
Consistency type to define consistency levels
const ( // Strong consistency level Strong Consistency = "strong" // Bounded consistency level Bounded Consistency = "bounded" // Session consistency level Session Consistency = "session" // Eventual consistency level Eventual Consistency = "eventual" )
type CosmosDB ¶
type CosmosDB struct { Config Config Logger *logger.Logger // contains filtered or unexported fields }
CosmosDB - Struct that stores the client and logger
func (*CosmosDB) CreateCollection ¶
func (c *CosmosDB) CreateCollection(db string, body interface{}, opts ...CallOption) (coll *Collection, err error)
CreateCollection - Creates a new collections in the database.
coll, err := client.CreateCollection("dbs/{db-id}/", `{"id": "coll-id"}`)
func (*CosmosDB) CreateDatabase ¶
func (c *CosmosDB) CreateDatabase(body interface{}, opts ...CallOption) (db *Database, err error)
CreateDatabase - Creates a new database in the database account.
db, err := client.CreateDatabase(`{ "id": "db-id" }`)
func (*CosmosDB) CreateDocument ¶
func (c *CosmosDB) CreateDocument(coll string, doc interface{}, opts ...CallOption) (*Response, error)
CreateDocument - Creates a new document in the collection.
err := client.CreateDocument("dbs/{db-id}/colls/{coll-id}", &doc)
func (*CosmosDB) CreateStoredProcedure ¶
func (c *CosmosDB) CreateStoredProcedure(coll string, body interface{}, opts ...CallOption) (sproc *Sproc, err error)
CreateStoredProcedure - Creates a new stored procedure in the collection.
sprocBody := gocosmosdb.Sproc{ Body: "function () {\r\n var context = getContext();\r\n var response = context.getResponse();\r\n\r\n response.setBody(\"Hello, World\");\r\n}", Id: "sproc_1" } sproc, err := client.CreateStoredProcedure("dbs/{db-id}/colls/{coll-id}/sprocs", &sprocBody)
func (*CosmosDB) CreateUserDefinedFunction ¶
func (c *CosmosDB) CreateUserDefinedFunction(coll string, body interface{}, opts ...CallOption) (udf *UDF, err error)
CreateUserDefinedFunction - Creates a new user defined function in the collection.
udfBody := gocosmosdb.UDF{ Body: "function tax(income) {\r\n if(income == undefined) \r\n throw 'no input';\r\n if (income < 1000) \r\n return income * 0.1;\r\n else if (income < 10000) \r\n return income * 0.2;\r\n else\r\n return income * 0.4;\r\n}", Id: "simpleTaxUDF" } udf, err := client.CreateUserDefinedFunction("dbs/{db-id}/colls/{coll-id}/udfs", &udfBody)
func (*CosmosDB) DeleteCollection ¶
DeleteCollection - Deletes a collection from a database.
err := client.DeleteCollection("dbs/{db-id}/colls/{coll-id}")
func (*CosmosDB) DeleteDatabase ¶
DeleteDatabase - Deletes a database from a database account.
err := client.DeleteDatabase("dbs/{db-id}")
func (*CosmosDB) DeleteDocument ¶
func (c *CosmosDB) DeleteDocument(link string, opts ...CallOption) (*Response, error)
DeleteDocument - Deletes a document from a collection.
err := client.DeleteDocument("dbs/{db-id}/colls/{coll-id}/docs/{doc-id}")
func (*CosmosDB) DeleteStoredProcedure ¶
DeleteStoredProcedure - Deletes a stored procedure from a collection.
err := client.DeleteStoredProcedure("dbs/{db-id}/colls/{coll-id}/sprocs/{sproc-id}")
func (*CosmosDB) DeleteUserDefinedFunction ¶
DeleteUserDefinedFunction - Deletes a user defined function from a collection.
err := client.DeleteUserDefinedFunction("dbs/{db-id}/colls/{coll-id}/udfs/{udf-id}")
func (*CosmosDB) DisableDebug ¶
func (c *CosmosDB) DisableDebug()
DisableDebug - disables the CosmosDB debugging
func (*CosmosDB) EnableDebug ¶
func (c *CosmosDB) EnableDebug()
EnableDebug - enables the CosmosDB debugging
func (*CosmosDB) ExecuteStoredProcedure ¶
func (c *CosmosDB) ExecuteStoredProcedure(link string, params, body interface{}, opts ...CallOption) (resp *Response, err error)
ExecuteStoredProcedure - Executes a stored procedure and marshals the data into the passed interface.
err := client.ExecuteStoredProcedure("dbs/{db-id}/colls/{coll-id}/sprocs/{sproc-id}", []interface{}{p1, p2}, &docs)
func (*CosmosDB) NewPagableQuery ¶
func (c *CosmosDB) NewPagableQuery(coll string, query *QueryWithParameters, limit int, docs interface{}, opts ...CallOption) *PagableQuery
NewPagableQuery - Creates a pagable query that populates the passed docs interface
func (*CosmosDB) QueryCollections ¶
func (c *CosmosDB) QueryCollections(db, query string, opts ...CallOption) (colls []Collection, err error)
QueryCollections - Retrieves all collections that satisfy passed query.
colls, err := client.QueryCollections("SELECT * FROM ROOT r")
func (*CosmosDB) QueryDatabases ¶
func (c *CosmosDB) QueryDatabases(query string, opts ...CallOption) (dbs []Database, err error)
QueryDatabases - Retrieves all databases that satisfy the passed query.
dbs, err := client.QueryDatabases("SELECT * FROM ROOT r")
func (*CosmosDB) QueryDocuments ¶
func (c *CosmosDB) QueryDocuments(coll, query string, docs interface{}, opts ...CallOption) (resp *Response, err error)
QueryDocuments - Retrieves all documents in a collection that satisfy the passed query and marshals them into the passed interface.
err := client.QueryDocuments(coll, "SELECT * FROM ROOT r", &docs)
func (*CosmosDB) QueryDocumentsWithParameters ¶
func (c *CosmosDB) QueryDocumentsWithParameters(coll string, query *QueryWithParameters, docs interface{}, opts ...CallOption) (resp *Response, err error)
QueryDocumentsWithParameters - Retrieves all documents in a collection that satisfy a passed query with parameters and marshals them into the passed interface.
err := client.QueryDocumentsWithParameters(coll, queryWithParams, &docs)
func (*CosmosDB) QueryPartitionKeyRanges ¶
func (c *CosmosDB) QueryPartitionKeyRanges(coll string, query string, opts ...CallOption) (ranges []PartitionKeyRange, err error)
QueryPartitionKeyRanges - Retrieves all partition ranges in a collection.
pks, err := client.QueryPartitionKeyRanges(coll, "SELECT * FROM ROOT r")
func (*CosmosDB) QueryStoredProcedures ¶
func (c *CosmosDB) QueryStoredProcedures(coll, query string, opts ...CallOption) (sprocs []Sproc, err error)
QueryStoredProcedures - Retrieves all stored procedures that satisfy the passed query.
colls, err := client.QueryStoredProcedures("SELECT * FROM ROOT r")
func (*CosmosDB) QueryUserDefinedFunctions ¶
func (c *CosmosDB) QueryUserDefinedFunctions(coll, query string, opts ...CallOption) (udfs []UDF, err error)
QueryUserDefinedFunctions - Retrieves all user defined functions that satisfy the passed query.
colls, err := client.QueryUserDefinedFunctions("SELECT * FROM ROOT r")
func (*CosmosDB) ReadCollection ¶
func (c *CosmosDB) ReadCollection(link string, opts ...CallOption) (coll *Collection, err error)
ReadCollection - Retrieves a collection by performing a GET on a specific collection resource.
coll, err := client.ReadCollection("dbs/{db-id}/colls/{coll-id}")
func (*CosmosDB) ReadCollections ¶
func (c *CosmosDB) ReadCollections(db string, opts ...CallOption) (colls []Collection, err error)
ReadCollections - Retrieves all collections by performing a GET on a specific database.
colls, err := client.ReadCollections("dbs/{db-id}/colls")
func (*CosmosDB) ReadDatabase ¶
func (c *CosmosDB) ReadDatabase(link string, opts ...CallOption) (db *Database, err error)
ReadDatabase - Retrieves a database resource by performing a GET on the database resource.
db, err := client.ReadDatabase("dbs/{db-id}")
func (*CosmosDB) ReadDatabases ¶
func (c *CosmosDB) ReadDatabases(opts ...CallOption) (dbs []Database, err error)
ReadDatabases - Retrieves all databases by performing a GET on a specific account.
dbs, err := client.ReadDatabases("dbs")
func (*CosmosDB) ReadDocument ¶
func (c *CosmosDB) ReadDocument(link string, doc interface{}, opts ...CallOption) (resp *Response, err error)
ReadDocument - Retrieves a document by performing a GET on a specific document resource and marshals the document into that passed docStruct
err = client.ReadDocument("dbs/{db-id}/colls/{coll-id}/docs/{doc-id}", &docStruct)
func (*CosmosDB) ReadDocuments ¶
func (c *CosmosDB) ReadDocuments(coll string, docs interface{}, opts ...CallOption) (*Response, error)
ReadDocuments - Retrieves a stored procedure by performing a GET on a specific stored procedure resource.
err = client.ReadDocuments("dbs/{db-id}/colls/{coll-id}/docs", &docStructSlice)
func (*CosmosDB) ReadStoredProcedure ¶
func (c *CosmosDB) ReadStoredProcedure(link string, opts ...CallOption) (sproc *Sproc, err error)
ReadStoredProcedure - Retrieves a stored procedure by performing a GET on a specific stored procedure resource. sproc, err := client.ReadStoredProcedure("dbs/{db-id}/sprocs/{sproc-id}")
func (*CosmosDB) ReadStoredProcedures ¶
func (c *CosmosDB) ReadStoredProcedures(coll string, opts ...CallOption) (sprocs []Sproc, err error)
ReadStoredProcedures - Retrieves all stored procedures by performing a GET on a specific database.
sprocs, err := client.ReadStoredProcedures("dbs/{db-id}/sprocs")
func (*CosmosDB) ReadUserDefinedFunction ¶
func (c *CosmosDB) ReadUserDefinedFunction(link string, opts ...CallOption) (udf *UDF, err error)
ReadUserDefinedFunction - Retrieves a user defined function by performing a GET on a specific user defined function resource. udf, err := client.ReadUserDefinedFunction("dbs/{db-id}/udfs/{udf-id}")
func (*CosmosDB) ReadUserDefinedFunctions ¶
func (c *CosmosDB) ReadUserDefinedFunctions(coll string, opts ...CallOption) (udfs []UDF, err error)
ReadUserDefinedFunctions - Retrieves all user defined functions by performing a GET on a specific database.
udfs, err := client.ReadUserDefinedFunctions("dbs/{db-id}/udfs")
func (*CosmosDB) ReplaceDatabase ¶
func (c *CosmosDB) ReplaceDatabase(link string, body interface{}, opts ...CallOption) (db *Database, err error)
ReplaceDatabase - Replaces a existing database in a database account.
db, err := client.ReplaceDatabase("dbs/{db-id}", "`{ "id": "new-db-id" }`)
func (*CosmosDB) ReplaceDocument ¶
func (c *CosmosDB) ReplaceDocument(link string, doc interface{}, opts ...CallOption) (*Response, error)
ReplaceDocument - Replaces a existing document in a collection.
db, err := client.ReplaceDocument("dbs/{db-id}/colls/{coll-id}/docs/{doc-id}", &doc)
func (*CosmosDB) ReplaceDocumentAsync ¶
func (c *CosmosDB) ReplaceDocumentAsync(link string, doc interface{}, opts ...CallOption) (*Response, error)
ReplaceDocumentAsync - Replaces a document that has a matching etag.
db, err := client.ReplaceDocumentAsync("dbs/{db-id}/colls/{coll-id}/docs/{doc-id}", &doc)
func (*CosmosDB) ReplaceStoredProcedure ¶
func (c *CosmosDB) ReplaceStoredProcedure(link string, body interface{}, opts ...CallOption) (sproc *Sproc, err error)
ReplaceStoredProcedure - Replaces a stored procedure in a collection.
db, err := client.ReplaceDatabase("dbs/{db-id}/colls/{coll-id}/sprocs/{sproc-id}", &sprocBody)
func (*CosmosDB) ReplaceUserDefinedFunction ¶
func (c *CosmosDB) ReplaceUserDefinedFunction(link string, body interface{}, opts ...CallOption) (udf *UDF, err error)
ReplaceUserDefinedFunction - Replaces a user defined function in a collection.
db, err := client.ReplaceDatabase("dbs/{db-id}/colls/{coll-id}/udfs/{udf-id}", &udfBody)
func (*CosmosDB) UpsertDocument ¶
func (c *CosmosDB) UpsertDocument(coll string, doc interface{}, opts ...CallOption) (*Response, error)
UpsertDocument - Creates a new document or replaces the existing document with matching id in the collection.
err := client.UpsertDocument("dbs/{db-id}/colls/{coll-id}", &doc)
type Database ¶
type Database struct { Resource Colls string `json:"_colls,omitempty"` Users string `json:"_users,omitempty"` }
Database
type IndexingPolicy ¶
type IndexingPolicy struct { Automatic bool `json:"automatic,omitempty"` IncludedPaths []struct { Indexes []struct { DataType string `json:"dataType,omitempty"` Kind string `json:"kind,omitempty"` Precision int `json:"precision,omitempty` } `json:"indexes,omitempty"` Path string `json:"path,omitempty"` } `json:"includedPaths,omitempty"` IndexingMode string `json:"indexingMode,omitempty"` }
Indexing policy
type Metrics ¶
type Metrics struct { TotalExecutionTimeInMs float64 `json:"totalExecutionTimeInMs,omitempty"` QueryCompileTimeInMs float64 `json:"queryCompileTimeInMs,omitempty"` QueryLogicalPlanBuildTimeInMs float64 `json:"queryLogicalPlanBuildTimeInMs,omitempty"` QueryPhysicalPlanBuildTimeInMs float64 `json:"queryPhysicalPlanBuildTimeInMs,omitempty"` QueryOptimizationTimeInMs float64 `json:"queryOptimizationTimeInMs,omitempty"` VMExecutionTimeInMs float64 `json:"VMExecutionTimeInMs,omitempty"` IndexLookupTimeInMs float64 `json:"indexLookupTimeInMs,omitempty"` DocumentLoadTimeInMs float64 `json:"documentLoadTimeInMs,omitempty"` SystemFunctionExecuteTimeInMs float64 `json:"systemFunctionExecuteTimeInMs,omitempty"` UserFunctionExecuteTimeInMs float64 `json:"userFunctionExecuteTimeInMs,omitempty"` RetrievedDocumentCount int `json:"retrievedDocumentCount,omitempty"` RetrievedDocumentSize int `json:"retrievedDocumentSize,omitempty"` OutputDocumentCount int `json:"outputDocumentCount,omitempty"` WriteOutputTimeInMs float64 `json:"writeOutputTimeInMs,omitempty"` IndexUtilizationRatio float64 `json:"indexUtilizationRatio,omitempty"` RequestCharge float64 `json:"requestCharge,omitempty"` }
Metrics
type PagableQuery ¶
type PagableQuery struct {
// contains filtered or unexported fields
}
PagableQuery
func (*PagableQuery) Done ¶
func (q *PagableQuery) Done() bool
Done - returns true if no more pages are available
func (*PagableQuery) Next ¶
func (q *PagableQuery) Next() error
Next - marshals the next page of docs into the passed interface
type PartitionKeyDef ¶
Partition Key
type PartitionKeyRange ¶
type PartitionKeyRange struct { Resource MinInclusive string `json:"minInclusive,omitempty"` MaxInclusive string `json:"maxExclusive,omitempty"` }
PartitionKeyRange partition key range model
type QueryParameter ¶
type QueryParameter struct { Name string `json:"name"` Value interface{} `json:"value"` }
QueryParameter
type QueryWithParameters ¶
type QueryWithParameters struct { Query string `json:"query"` Parameters []QueryParameter `json:"parameters"` }
QueryWithParameters
type Request ¶
Resource Request
func ResourceRequest ¶
Return new resource request with type and id
func (*Request) DefaultHeaders ¶
Add 3 default headers to *Request "x-ms-date", "x-ms-version", "authorization"
func (*Request) QueryHeaders ¶
Add headers for query request
func (*Request) QueryMetricsHeaders ¶
func (req *Request) QueryMetricsHeaders()
Add headers for query metrics request
type RequestError ¶
type RequestError struct { Code string `json:"code"` StatusCode int `json:"statusCode"` Message string `json:"message"` RId string `json:"rId"` RType string `json:"rType` Request *http.Request `json:"request"` }
RequestError
type Resource ¶
type Resource struct { Id string `json:"id,omitempty"` Self string `json:"_self,omitempty"` Etag string `json:"_etag,omitempty"` Rid string `json:"_rid,omitempty"` Ts int `json:"_ts,omitempty"` Count int `json:"_count,omitempty"` }
Resource
type Response ¶
func (*Response) Continuation ¶
Continuation - returns continuation token for paged request. Pass this value to next request to get next page of documents.
func (*Response) GetQueryMetrics ¶
GetQueryMetrics - returns a responses metrics
func (*Response) SessionToken ¶
SessionToken - returns session token for session consistent request. Pass this value to next request to maintain session consistency documents.