Importing Data - MongoDB

By peterm, 27 January, 2015

Importing to Mongo via jsonArray

mongoimport -d meanjs-leaflet4-dev -c leaflets -f name,coordinates --type json --file building-addresses.json --jsonArray

// sample file

// notes - coordinates needs to be bracketed to indicate an array otherwise we get string

// created - use a yyyy-mm-dd for basic entry

    [

    {

      "name": "Cowell College - Apartment  2",

      "coordinates": ["36.981798, -122.050032"],

      "created": "2015-01-29 " // yyyy-mm-dd

    },

    {

      "name": "TAPS Parking Lot 108 - Cowell College",

      "coordinates": ["36.997739, -122.053217"],

      "created": "2015-01-29"

    }

]

Found this article very helpful. 

http://zaiste.net/2012/08/importing_json_into_mongodb/

Tags