Documentation ¶
Overview ¶
Package clouddatastore provides Cloud Datastore implementation of datastore.Client. This package wrapping cloud.google.com/go/datastore package.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromContext ¶
FromContext make new Client by specified context.
Example ¶
package main import ( "context" "fmt" "go.mercari.io/datastore" "go.mercari.io/datastore/clouddatastore" "go.mercari.io/datastore/internal/testutils" ) const ProjectID = "datastore-wrapper" func main() { ctx := context.Background() client, err := clouddatastore.FromContext( ctx, datastore.WithProjectID(ProjectID), ) if err != nil { panic(err) } defer client.Close() defer testutils.CleanUpAllEntities(ctx, client) type Data struct { Name string } key := client.IncompleteKey("Data", nil) entity := &Data{Name: "mercari"} key, err = client.Put(ctx, key, entity) if err != nil { panic(err) } entity = &Data{} err = client.Get(ctx, key, entity) if err != nil { panic(err) } fmt.Println(entity.Name) }
Output: mercari
func IsCloudDatastoreClient ¶
IsCloudDatastoreClient returns check result that client is this package's client or not.
Types ¶
This section is empty.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.