Monday 1 May 2017

Loading Data into MongoDB using external script

I have a script, where I am making use of the mongo shell to load in some initial data using the load() method. But it seems to fail on the very first line, with the following error

TypeError: db.getSibilingDB is not a function

Here is my script

db = db.getSibilingDB('queued')
db.createCollection('restaurantList')
restaurantListCollection = db.getCollection('restaurantList')
restaurantListCollection.remove({})
restaurantListCollection.insert({
    name:"RestaurantA",
    address: "Cherry Street 14",
    waitTime: "15-20"
})
restaurantListCollection.insert({
    name:"RestaurantB",
    address: "Columbus Street 29",
    waitTime: "5-7"
})
restaurantListCollection.insert({
    name:"RestaurantA",
    address: "12th Street",
    waitTime: "10-15"
})



via RRP

No comments:

Post a Comment