googleapis / googleapis/google-cloud-go

datastore: versioned mutations

Open
#3,756 3 comments 2 reactions 1 assignee Assigned to @bhshkh View on GitHub
api: datastore priority: p2 type: feature request
Dominant language
Go
Stars
4.5k
Forks
1.6k
Avg merge
1d 13h
Merged PRs (30d)
109

Description

**Is your feature request related to a problem? Please describe.**
Looking through the internal code of the Datastore library, I notice that the LookupResult and Mutation both have properties with a 'version' field. The entities in the Datastore apparently have a version and it would be possible to create mutations that are rejected because the entity is outdated.

This kind of optimistic locking is precisely what I'd like to use. However, the current Datastore library does not expose this.

**Describe the solution you'd like**
Just like the Datastore currently supports loading Key's into `__key__` labeled fields (KeyLoader), the library could also support loading the version into `__version__` labeled fields (VersionLoader). Then any update/mutation could reinstantiate this `__version__` value into the Mutation.

**Describe alternatives you've considered**
Alternatives like extending the user API via options would be troublesome and cumbersome for existing users of the library to implement. The `__version__` addition would be fairly invisible for existing users. Through the documentation we can explain this feature.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.