0
votes

I have an Google App Engine entity called MyFile. It has properties such as name, size, path, parentFolder.

Rather than querying to return all the MyFile entities where parent is null like this
Query<MyFile> q1 = objectify.query(MyFile.class).filter("parentFolder", null);

I want to return a list of just the 'name' values where parent is null (eg List<String>), rather than the entire collection of MyFile entities

How do you do that?

1

1 Answers

1
votes

You cannot retrieve particular fields by themselves. It is the nature of the datastore that entities are returned whole or not at all.

If you really need to exclude some fields from retrieval during a query, you must separate them into a separate entity type. Unless you're talking about large blob fields, this will almost always be slower and more expensive than storing and retrieving a single entity. Don't prematurely optimize - unless you have a known problem, don't complicate your data model.