I am trying to write a datastore query in NodeJS.
I want to order by timestamp but also only distinct unique ID's (no duplicates) and only retrieve the latest datastore item for each unique ID.
For example
USER_ID - TIMESTAMP
10 - 1000
10 - 500
5 - 10
5 - 1500
5 - 50
I want the query to result with
USER_ID - TIMESTAMP
10 - 1000
5 - 1500
What I've tried:
datastore.createQuery('example')
.groupBy('USER_ID')
.order('USER_ID')
.order('TIMESTAMP')
But it returns the data ordered by USER_ID
, not TIMESTAMP
from Order By and Group By in Google Datastore Node JS
No comments:
Post a Comment