Teddy
Teddy

Reputation: 4253

Objectify - get all of a type regardless of parent

I have child entities with @Parent key ref in them.

When I give the parent key, I am able to get the child entity like this:

OfyService.ofy()
            .load()
            .type(Child.class)
            .parent(parentKey)
            .id(childId).now();

I tried to access the child entity directly without giving the parent key, but that doesn't work (returns null):

OfyService.ofy()
            .load()
            .type(Child.class)
            .id(childId).now();

Is there another way to query one or all instances of a kind regardless of parent?

For example, _ah/admin is able to list all the entities of a Kind regardless of the parent.

Upvotes: 0

Views: 293

Answers (1)

stickfigure
stickfigure

Reputation: 13556

Iterable<Child> children = ofy().load().type(Child.class);

Upvotes: 1

Related Questions