Closed cgarciae closed 9 years ago
You can use the @ReferenceId annotation (it isn't documented yet, but I hope to fix that soon)
@ReferenceId
List<String> ids;
@luizmineo Thanks man! You always save me.
I've been depending on your code a lot and I would like to contribute back atleast with documentation. Tell me if you need anything.
Ok, so now I have a list of String
s that are the ids of some objects in the DB. How do I use this list to FIND those objects?
That depends on how you are building your query. For example, if you want to retrieve all objects with a single query, you can do the following:
var selector = where.oneFrom("_id", myOuterObj.ids.map((i)
=> new ObjectId.fromHexString(i)).toList());
mongoDb.find("mycollection", MyInnerType, selector);
Let me know if that helps
Thanks! Id been looking for $in
but now I see it's a reserved word so they had to come up with oneFrom
.
In the example in the docs you use
to interact with mongo's Id Object. However, it is common for you have a list of ids of objects in another collection. How do I make that query and/or structure my class?