go sdk for Azure Cosmos DB
-
no
_selflinks -
full support for partitioned collections
-
simple interface
-
supports all operations with user defined ids
-
naming conventions follow the RestAPI https://docs.microsoft.com/en-us/rest/api/cosmos-db/
-
it more closely follows the api of the official SDKs
-
instantiate a
configstruct. Set the keys, url and some other parameters. -
call the constructor
New(cfg config) -
cosmosdbfollows the hierarchy of Cosmos DB. This means that you can operate on the resource the current type represents. The database struct can work with resources that belong to a cosmos database, theCollectiontype can work with resources that belong to a collection. -
doc interface{}may seem weird in some contexts, e.g.DeleteDocument, why not use a signature likeDeleteDocument(ctx context.Context, id string). The reason is that there are several ways to address the document. Either by self link, with or without_etagor by theid. All on collections with or without a partition key.- use
_selfif possible - if
_etagis present, use it - otherwise use id
- if neither exists -> error
- use
type Document struct {
id string
}
newDoc, err := coll.CreateDocument(context.Background(), doc)
#FAQ