[DOCS-6208] Comment on: "manual/reference/operator/update/pull.txt" Created: 15/Sep/15  Updated: 30/Oct/23  Resolved: 17/Oct/18

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Bug Priority: Major - P3
Reporter: Docs Collector User (Inactive) Assignee: Unassigned
Resolution: Done Votes: 0
Labels: bite-sized, docs-triage
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

windows 8

Location: http://docs.mongodb.org/manual/reference/operator/update/pull/#up._S_pull
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36
Referrer: http://docs.mongodb.org/manual/reference/operator/update-array/
Screen Resolution: 1366 x 768
repo: docs
source: reference/operator/update/pull


Participants:
Days since reply: 5 years, 17 weeks ago
Epic Link: DOCSP-1769
Story Points: 0.25

 Description   

{
_id: 1,
results: [

{ item: "A", score: 5 }

,

{ item: "B", score: 8, comment: "Strongly agree" }

]
}
{
_id: 2,
results: [

{ item: "C", score: 8, comment: "Strongly agree" }

,

{ item: "B", score: 4 }

]
}
The following operation will remove from the results array all elements that contain both a score field equal to 8 and an item field equal to "B":

db.survey.update(
{ },
{ $pull: { results:

{ score: 8 , item: "B" }

} },

{ multi: true }

)

here the $pull operator does not remove result with

{score:8,item:"B"}

as $pull for array of documents requires all fields to match.



 Comments   
Comment by Kay Kim (Inactive) [ 17/Oct/18 ]

per documentation:

Because $pull operator applies its query to each element as though it were a top-level object, the expression did not require the use of $elemMatch to specify the condition of a score field equal to 8 and item field equal to "B".

{document}
Generated at Thu Feb 08 07:51:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.