i using relay/graphql/googlecloud setup project saves data immutably.
i have set of fields create new record each time modification made of fields structured so:
project - start date - end date - description - ... - ...
the first time project created saved timestamp , version number. example:
1470065550-1
any modifications after creates new version number still uses same timestamp.
1470065550-2
bearing in mind immutable there potentially lot of versions of 1 project. if there lot of projects result in large number of records being fetched
if want fetch list of projects datastore returning latest version of each 1 best way of going this? version number increments never know 1 latest.
for example if had rows containing 2 projects, both multiple versions , want fetch latest version of each:
1470065550-1 1470065550-2 1470065550-3 1470065550-4 1470065550-5 1470065550-6 1470065550-7 <--- current version 1470065550 1567789887-1 1567789887-2 1567789887-3 <--- current version 1567789887
based on rows above need query return latest version of 2 projects:
1470065550-7 <--- current version 1470065550 1567789887-3 <--- current version 1567789887
you want change tag [google-cloud-datastore] instead of [google-cloud-storage] because you're missing people experts on datastore.
but offer 2 cents on question: may easiest add field "current" , use transaction switch atomically. easy filter use in other query.
if can't that, it's bit tricky answer question because haven't given query building set of results. typical way of getting max value sort , set limit of 1 so:
var query = datastore .createquery('projects') .order('timestamp') .limit(1);
but given way storing data, don't think can when run on -9 -10 because -10 comes before -9 in lexicographical sorts (i didn't check how works in datastore, however). might need 0 pad.
Comments
Post a Comment