Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
findAndModify and Pull operation.
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
zhengchun  
View profile  
 More options Jul 2 2012, 11:53 am
From: zhengchun <zhengchuns...@gmail.com>
Date: Mon, 2 Jul 2012 08:53:40 -0700 (PDT)
Local: Mon, Jul 2 2012 11:53 am
Subject: findAndModify and Pull operation.

hello,everyone,i have similar following data
{
  _id,
 ....
 items:[
    {
       id:1,
       ....
    },
    {
      id:2
      ....
    }
 ]

}

now,i want to delete the items.id=1 and return the other remain items .
my code like this:
            var query = Query.EQ("items.id", 1);
            var update = Update.Pull("items", Query.EQ("id",1"));
            var fields = Fields.Include(new string[] { "_id", "items" });
           var result=this.Collection.FindAndModify(query, SortBy.Null,
update, fields, true, false);

when i runing the above code,i get the error.

Command 'findAndModify' failed: E11000 duplicate key error index:
tobobay_prods.products.$items.id_1  dup key: { : null } (response: {
"lastErrorObject" : { "err" : "E11000 duplicate key error index:
tobobay_prods.products.$items.id_1  dup key: { : null }", "code" : 11001,
"n" : 0, "connectionId" : 52, "ok" : 1.0 }, "

someone can give me some suggestion?how Pull some item and return entire
data?
thanks.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
zhengchun  
View profile  
 More options Jul 2 2012, 2:48 pm
From: zhengchun <zhengchuns...@gmail.com>
Date: Mon, 2 Jul 2012 11:48:41 -0700 (PDT)
Local: Mon, Jul 2 2012 2:48 pm
Subject: Re: findAndModify and Pull operation.

sorry,i notice this error is the* items.id* as index because it.if i delete*items.id
* index,everything is good.

http://stackoverflow.com/questions/8639212/e11000-duplicate-key-error...

在 2012年7月2日星期一UTC+8下午11时53分40秒,zhengchun写道:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dwight Merriman  
View profile  
 More options Jul 2 2012, 11:45 pm
From: Dwight Merriman <dwi...@10gen.com>
Date: Mon, 2 Jul 2012 20:45:36 -0700 (PDT)
Local: Mon, Jul 2 2012 11:45 pm
Subject: Re: findAndModify and Pull operation.

$pull on "items.id":1 won't work as "items.id" is not an array.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dwight Merriman  
View profile  
 More options Jul 3 2012, 10:11 am
From: Dwight Merriman <dwi...@10gen.com>
Date: Tue, 3 Jul 2012 07:11:05 -0700 (PDT)
Local: Tues, Jul 3 2012 10:11 am
Subject: Re: findAndModify and Pull operation.

whoops, pull on "items.id" doesn't work but {items:{id:...}} does work in
newer versions.

db.mycollection.update({"items.id":1},{$pull:{items:{id:1}}}) // ok


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »