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 FromClient ¶
FromClient make new Client by specified datastore.Client.
func FromContext ¶
FromContext make new Client by specified context. Deprecated: use FromClient instead of FromContext. FromContext implicitly creates original datastore.Client.
Example ¶
package main import ( "context" "fmt" "go.mercari.io/datastore/v2" "go.mercari.io/datastore/v2/clouddatastore" "go.mercari.io/datastore/v2/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.