$pull with $lt condition on each object

43 views
Skip to first unread message

Ben Dilts

unread,
Aug 10, 2011, 2:35:48 PM8/10/11
to mongod...@googlegroups.com
I'm using the PHP client, and I'm trying to remove all members of the "changes" array where "idx" is less than 50.

$db->documents->update(
array(
'_id'=>$doc['_id']
),
array(
'$pull' => array(
'changes' => array(
'idx' => array(
'$lt' => 50
)
)
)
)
);

This code doesn't seem to work--worse, it makes my Apache process hang at 100% CPU until PHP times it out after 30 seconds. Anyway, how should I perform such an update?

Ben Dilts

unread,
Aug 10, 2011, 3:01:38 PM8/10/11
to mongod...@googlegroups.com
Aha! Turns out I was attempting to do a $set on the same array I was trying to $pull on, which caused the hangup in Apache. Regardless, the $pull still doesn't seem to be working.

Ben Dilts

unread,
Aug 10, 2011, 3:05:48 PM8/10/11
to mongod...@googlegroups.com
No, it appears that did catch all of it. Anyway, it looks like I should probably file a bug, since bad input to update() shouldn't hang up the PHP mongo client.

Kristina Chodorow

unread,
Aug 10, 2011, 4:43:39 PM8/10/11
to mongodb-user
This executes instantly for me. Are you using lazy connections or
safe parameters?
Reply all
Reply to author
Forward
0 new messages