Hi Shane and thanks a lot for your answer.
However I think I’m still a bit confused.
The syntax you suggested allow to find the parent image from the database, based on the label ID. But I’m looking for the embedded label itself. Are you suggesting that I then find the embedded label in a second step, with something like this?
label = next((label for label in image.labels if label._id==label_id), None)
My first intuition was to query the embedded label directly from the database, with something like:
label = Image.objects.get(id=image_id).labels.get(id=label_id)
This query indeed requires to know the parent image ID, which I can obtain in a previous step with something like:
image_id = Image.objects(labels__id=label_id).first().id
Does this solution seem wrong to you?
Thanks also for your remark on using _id
on EmbeddedDocuments. I must admit that I can’t get my head around not using these IDs. I feel like they are very useful to identify a given embedded document without relying on all its unique fields. But this probably shows that I haven’t yet fully understood how to work with document-oriented databases.