What version of MongoDB are you running? I think that this restriction
was lifted in the 1.1.x series (and the positional operator wasn't
added until 1.3.x IIRC). Should probably make sure you're using at
least 1.4
On Mon, Apr 26, 2010 at 11:31 AM, Steve Doublon
<
sts.i...@googlemail.com> wrote:
> Hi all,
>
> I would appreciate any advice on this, I'm pretty new to Mongo:
>
> I'm having some problems with updating values in a list.
> I have documents in a collection like this:
>
> {
> "movie":"Pulp Fiction",
> "cast":["Samuel","John"]
> }
>
> {
> "movie":"Swordfish",
> "cast":["John","Hugh", Halle"]
> }
>
> with an index on the "cast" list.
>
> Then in all documents that have the name "John" I want to update the
> name to "John Travolta" using the positional operator $ on the cast
> list:
>
> db.movies.update({cast:"John"},{$set: {'cast.$':"John Travolta"}}
> false,true)
>
> What I'm getting with the index on "cast" is this error message:
> "E12010 can't $inc/$set an indexed field"
>
> (And the question arises, how can I update indexed fields?)
>
> But even when I remove the index it still does not work, only with a
> different message this time:
>
> "Modifier spec implies existence of an encapsulating object with a
> name that already represents a non-object, or is referenced in another
> $set clause"
>
> Would be happy to get an idea about what I'm getting wrong here...
>
> Thanks a lot,
> Steve
>
> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to
mongod...@googlegroups.com.
> To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/mongodb-user?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to
mongod...@googlegroups.com.
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/mongodb-user?hl=en.