Skip to content

Commit

Permalink
add delete by key
Browse files Browse the repository at this point in the history
  • Loading branch information
acoshift committed Apr 6, 2017
1 parent cf836a2 commit ab3c8be
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ import (
"cloud.google.com/go/datastore"
)

// DeleteByKey deletes data from datastore by key
func (client *Client) DeleteByKey(ctx context.Context, key *datastore.Key) error {
err := client.Delete(ctx, key)
if client.Cache != nil {
client.Cache.Del(key)
}
return err
}

// DeleteByKeys deletes data from datastore by keys
func (client *Client) DeleteByKeys(ctx context.Context, keys []*datastore.Key) error {
err := client.DeleteMulti(ctx, keys)
if client.Cache != nil {
client.Cache.DelMulti(keys)
}
return err
}

// DeleteByID deletes data from datastore by IDKey
func (client *Client) DeleteByID(ctx context.Context, kind string, id int64) error {
if id == 0 {
Expand Down

0 comments on commit ab3c8be

Please sign in to comment.