Hi Folks,
I'm exploring appengine (java), and as per subject, how do I, using DatastoreService, get an Entity based on Key and conditions?
In my scenario, Trainer's have many to many relationship with User's, so I have my structure as so
Trainer(id, name, type, department)
User(id, name, address, is_activated)
TrainerUser(id, trainer_id, user_id)
Now to get all User under a particular Trainer, I'd fetch all the user_id from TrainerUser filtering by trainer_id. All's ok. Then I want to get all activated User under the Trainer, so my plan is to loop over the fetched user_id's and call something like
Query q = new Entity('User');
q.addFilter('Key', EQUAL, userId);
q.addFilter('is_activated', EQUAL, True);
But as far as I know, Key is not a real physical property in which you can access using addFilter(), so the code at the top will just return me an empty Entity.
Is there a way to reference Key in the Entity? Any magic keyword for that?