We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have a document like this:
{ "_id": ObjectId("user1"), "addresses": [ { "id": ObjectId("a1"), "details": [....] }, { "id": ObjectId("a2"), "details": [....] } ], }
I want to get the details of document a1 only.
a1
When using this code, it returns a document with the full embedded array
address = await engine.find_one(User, {"_id": ObjectId("user1"), "addresses": { "$elemMatch": { "id": ObjectId("a1") } }})
It returns: { "_id" : ObjectId("user1"), "addresses" : [ { "id" : ObjectId("a1"), "details" : [....]}, { "id" : ObjectId("a2"), "details" : [....]}, .... <rest of array>... ] }
{ "_id" : ObjectId("user1"), "addresses" : [ { "id" : ObjectId("a1"), "details" : [....]}, { "id" : ObjectId("a2"), "details" : [....]}, .... <rest of array>... ] }
When I use the mongo shell: db.users.find({_id: ObjectId("user1")}, {addresses: { $elemMatch: {"id": ObjectId("a1")} }}) It returns: { "_id" : ObjectId("user1"), "addresses" : [ { "id" : ObjectId("a1"), "details" : [....]} ] }
db.users.find({_id: ObjectId("user1")}, {addresses: { $elemMatch: {"id": ObjectId("a1")} }})
{ "_id" : ObjectId("user1"), "addresses" : [ { "id" : ObjectId("a1"), "details" : [....]} ] }
python -c "import pydantic.utils; print(pydantic.utils.version_info())"
Additional context
Sorry If I missed something, It's my first time working with NoSQL
The text was updated successfully, but these errors were encountered:
Hi no worries. Just to confirm, Is it normal that you use both campaigns and addresses ?
campaigns
addresses
Sorry, something went wrong.
No... sorry, my bad. My original db has campaigns, I only replaced names here for simplifications. So it's adresses not campaigns. Apologies.
adresses
No branches or pull requests
Bug
I have a document like this:
I want to get the details of document
a1
only.Current Behavior
When using this code, it returns a document with the full embedded array
It returns:
{ "_id" : ObjectId("user1"), "addresses" : [ { "id" : ObjectId("a1"), "details" : [....]}, { "id" : ObjectId("a2"), "details" : [....]}, .... <rest of array>... ] }
Expected behavior
When I use the mongo shell:
db.users.find({_id: ObjectId("user1")}, {addresses: { $elemMatch: {"id": ObjectId("a1")} }})
It returns:
{ "_id" : ObjectId("user1"), "addresses" : [ { "id" : ObjectId("a1"), "details" : [....]} ] }
Environment
python -c "import pydantic.utils; print(pydantic.utils.version_info())"
): 1.7.3Additional context
Sorry If I missed something, It's my first time working with NoSQL
The text was updated successfully, but these errors were encountered: