Skip to content

jewzaam/go-cosmosdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-cosmosdb

Minimal go cosmosdb rest client generator. Repository helps to generate go clients for cosmosdb based on the go structs.

https://docs.microsoft.com/en-gb/rest/api/cosmos-db

Tests

Tests expects CosmosDB database to to be present.

  1. Create cosmosdb for our example:
# create resource group
az group create --name  go-cosmosdb-test-rg --location eastus
# create cosmosdb
az cosmosdb create --name go-cosmosdb-test --resource-group go-cosmosdb-test-rg
  1. Create env file from env.example example
export RESOURCEGROUP=go-cosmosdb-test-rg
export COSMOSDB_ACCOUNT=go-cosmosdb-test
export COSMOSDB_KEY=$(az cosmosdb keys list -g $RESOURCEGROUP -n $COSMOSDB_ACCOUNT --query primaryMasterKey -o tsv)
  1. Run test
source ./env
make test

Example

See example/hello-world folder for code example.

Clients are generated by executing make generate. Generators are defined in example/cosmosdb/generate.go where we tell library to generate us clients for Person and People structures/documents.

//go:generate go run github.com/jewzaam/go-cosmosdb/cmd/gencosmosdb github.com/jewzaam/go-cosmosdb/example/types,Person,People
//go:generate gofmt -s -w .

Run example:

source ./env
go run ./example/hello-world

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published