Igorekk
Igorekk

Reputation: 256

Mongoimport upsert problem

I have file with this JSON

{
_id :     10000000042,
OtherID: 10000000043,
}

C:\mongodb-win32-i386-1.9.0\bin>mongoimport.exe --host localhost --db crm --collection tst --file c:\temp\tst3.txt --jsonArray --upsert --upsertFields OtherID

connected to: localhost imported 1 objects

In mongo console:

    > db.tst.find();
    { "_id" : NumberLong("10000000042"), "OtherID" : NumberLong("10000000043") }

> db.tst.getIndexes()
[
        {
                "name" : "_id_",
                "ns" : "crm.tst",
                "key" : {
                        "_id" : 1
                },
                "v" : 0
        },
        {
                "_id" : ObjectId("4e435d7a296ca66d8f50b0e0"),
                "ns" : "crm.tst",
                "key" : {
                        "OtherID" : 1
                },
                "name" : "OtherID_1",
                "v" : 0
        }
]

Then i updates my JSON:

{
_id :     10000000042,
OtherID: 10000000044,
}

and run mongoimport again

In console:

    > db.tst.find();
    { "_id" : NumberLong("10000000042"), "OtherID" :NumberLong("10000000043") }

OtherID field does not updated.

My hands are broken?

Upvotes: 0

Views: 1084

Answers (1)

Remon van Vliet
Remon van Vliet

Reputation: 18605

Remove the "upsertFields" parameter and you're golden. That isn't needed for what you are trying to do here.

Upvotes: 3

Related Questions