私はload()メソッドを使用していくつかの初期データを読み込むためにmongoシェルを使用しているスクリプトを用意しています。しかし、それは次のようなエラー外部スクリプトを使用してMongoDBにデータをロードする
TypeError: db.getSibilingDB is not a function
で、非常に最初の行に失敗するようだと、ここでは、getSibilingDB
でスペルタイプミスを持っているように見えます私のスクリプト
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"
})
db.getSibilingDB( 'queued')の 'db'はmongodbデータベースインスタンスではありませんが、あなたの例からは分かりません。 – Jthorpe
@Jthorpeあなたは精巧に教えてください。db変数に何が起こる必要がありますか? – RRP
@Jthorpe thatsすべてのコードがあります。それ以降は、mongoシェルのuse load( 'loadDB.js')です。私はその前に何か他のことをしなければならないかどうか分からない。 – RRP