spanner: update spanner_delete_data sample
@@ -31,15 +31,15 @@ func delete(w io.Writer, db string) error {
}
defer client.Close()
- // Delete each of the albums by individual key,
- // then delete all the singers using a key range.
m := []*spanner.Mutation{
- spanner.Delete("Albums", spanner.Key{1, 1}),
- spanner.Delete("Albums", spanner.Key{1, 2}),
+ // Delete individual rows.
spanner.Delete("Albums", spanner.Key{2, 1}),
- spanner.Delete("Albums", spanner.Key{2, 2}),
spanner.Delete("Albums", spanner.Key{2, 3}),
- spanner.Delete("Singers", spanner.KeyRange{Start: spanner.Key{1}, End: spanner.Key{5}, Kind: spanner.ClosedClosed}),
+ // Delete a range of rows where the column key is >=3 and <5.
+ spanner.Delete("Singers", spanner.KeyRange{Start: spanner.Key{3}, End: spanner.Key{5}, Kind: spanner.ClosedOpen}),
+ // Delete remaining Singers rows, which will also delete the remaining
+ // Albums rows because Albums was defined with ON DELETE CASCADE.
+ spanner.Delete("Singers", spanner.AllKeys()),
}
_, err = client.Apply(ctx, m)
return err
