Documentation ¶
Overview ¶
Example ¶
package main import ( "context" "fmt" "github.com/chiyoi/az/identity" "github.com/chiyoi/iter/res" ) const ( EndpointCosmos = "https://neko03cosmos.documents.azure.com:443/" ) func main() { // Point CRUD example. cred, err := identity.DefaultCredential() client, err := res.R(cred, err, NewClient(EndpointCosmos, nil)) if err != nil { panic(err) } c, err := client.NewContainer("neko0001", "point_test") if err != nil { panic(err) } ctx := context.Background() var neko, neko1 string exist, err := PointExist(ctx, "neko")(c) if err != nil { panic(err) } if exist { err = PointRead(ctx, "neko", &neko1)(c) if err != nil { panic(err) } err = PointUpsert(ctx, "neko", "nyan")(c) if err != nil { panic(err) } err = PointRead(ctx, "neko", &neko)(c) if err != nil { panic(err) } err = PointDelete(ctx, "neko")(c) if err != nil { panic(err) } } else { err = PointUpsert(ctx, "neko", "nyan")(c) if err != nil { panic(err) } err = PointRead(ctx, "neko", &neko)(c) if err != nil { panic(err) } err = PointUpsert(ctx, "neko", "nyan1")(c) if err != nil { panic(err) } err = PointRead(ctx, "neko", &neko1)(c) if err != nil { panic(err) } } fmt.Println(neko) fmt.Println(neko1) }
Output: nyan nyan1
Index ¶
- Variables
- func CreateItem(ctx context.Context, client *azcosmos.ContainerClient, ...) (err error)
- func Exist(ctx context.Context, client *azcosmos.ContainerClient, ...) (exist bool, err error)
- func IsNoMoreItems(err error) bool
- func NewClient(endpoint string, o *azcosmos.ClientOptions) func(cred azcore.TokenCredential) (*azcosmos.Client, error)
- func PointDelete(ctx context.Context, key string) func(client *azcosmos.ContainerClient) (err error)
- func PointExist(ctx context.Context, key string) func(client *azcosmos.ContainerClient) (exist bool, err error)
- func PointRead(ctx context.Context, key string, value any) func(client *azcosmos.ContainerClient) (err error)
- func PointUpsert(ctx context.Context, key string, value any) func(client *azcosmos.ContainerClient) (err error)
- func Query(client *azcosmos.ContainerClient, partitionKey azcosmos.PartitionKey, ...) (next func(ctx context.Context, v any) (err error))
- type Schema
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoMoreItems = errors.New("no more items")
Functions ¶
func CreateItem ¶
func CreateItem(ctx context.Context, client *azcosmos.ContainerClient, partitionKey azcosmos.PartitionKey, item any) (err error)
func Exist ¶ added in v0.9.5
func Exist(ctx context.Context, client *azcosmos.ContainerClient, partitionKey azcosmos.PartitionKey, itemID string) (exist bool, err error)
func IsNoMoreItems ¶
func NewClient ¶ added in v0.9.4
func NewClient(endpoint string, o *azcosmos.ClientOptions) func(cred azcore.TokenCredential) (*azcosmos.Client, error)
func PointDelete ¶
func PointExist ¶ added in v0.9.5
func PointUpsert ¶ added in v0.9.7
Types ¶
Click to show internal directories.
Click to hide internal directories.