RushOrm icon indicating copy to clipboard operation
RushOrm copied to clipboard

Querying using objects getters and setters

Open danielkmb2 opened this issue 8 years ago • 1 comments

Hello,

I want to retrieve the parent of an object given one of child fields. Is there any way to archieve this?

ex. Dog has name, human has name and list of dogs. Given a dog`s name i want to know its humans name.

Thanks!

danielkmb2 avatar Sep 06 '16 09:09 danielkmb2

Hi,

I think this would have to be done in two searches.

Dog dog = new RushSearch().whereEqual("name", dogName).findSingle(Dog.class);
Parent parent = new RushSearch().whereEqual("listField", dog).findSingle();

It's unlikely you would want to use findSingle i'm sure you would want to use find and check there are actually results.

Hope that helps.

Thanks

Stuart-campbell avatar Sep 06 '16 11:09 Stuart-campbell