0

UPDATE: As Dan pointed out - eval still seems to be the only way in MongoDB.

I have a collection (organizations) looking like this:

{
    "_id": ObjectId("531d26898aa08582df2a65ac"),
    "country_code_id": 56,
    "created_at": "2012-06-16 18:37:13",
    ,
    "geopoint": [

    ],
    "id": 46773,
    "latitude": 50.9571,
    "longitude": 6.91227,
    "name": "xyz",
    "postalcode": "50825",
    "scheduled": null,
    "state": null,
    "updated_at": "2012-06-16 18:37:13"
}

Now I have to combine "longitude" and "latitude" and write them to the array "geopoint" in order to create a 2d index. I could get all documents and iterate over the result but that is not doable at 9+ million documents.

Nikolai Manek
  • 980
  • 6
  • 16
  • 1
    You probably want to run [`eval`](http://docs.mongodb.org/manual/reference/method/db.eval/). – Dan Dascalescu Mar 10 '14 at 04:25
  • Hi, thank you. I just looked at them and they refer to 1-4 year old versions of mongodb where update in the same document was not possible. Iterating over a result from ALL document is not an option as well. – Nikolai Manek Mar 10 '14 at 04:36
  • 1
    Nothing has changed since then regarding any ability to access the other fields of the doc being updated. – JohnnyHK Mar 10 '14 at 04:50
  • Thank you everyone. I am using eval now as Dan pointed out and see how long it will take. – Nikolai Manek Mar 10 '14 at 05:00

0 Answers0