GAE datastore, GetMulti () with projection?

My application groups many different kinds of data to report to the user, this report takes time to compile and it is useful for the user to see this snapshot later, so I save a copy of the data compiled into a separate view in the data store. Then maybe a few months later, the user pulled out a copy that I saved, but I want to query the datastore for only one specific state field for each object that might have changed since the initial run of the report, to see if that object has changed since they viewed the report for the first time.

So, I have all the keys I need, I could do datastore.GetMulti (). But there can be thousands of objects and each one has many fields, so I was wondering if there was a more efficient method to query the datastore to get just that one field rather than the entire dataset. Something like a combination of projection query and GetMulti (), but I can't find anything like this in the docs, am I missing something?

+3


source to share


1 answer


Projection queries do not have to be on only one object. You can do just that with a projection request. In your case, something like this:

q := datastore.NewQuery("EntityKindYouDefinedName").Project("status_property")

      



See the doc for more information on how to handle the results of this projection query.

+3


source







All Articles