How to access a preexisting collection with Mongoose?

前端 未结 6 2076
终归单人心
终归单人心 2020-11-28 00:53

I have a large collection of 300 question objects in a database test. I can interact with this collection easily through MongoDB\'s interactive she

6条回答
  •  失恋的感觉
    2020-11-28 01:18

    Are you sure you've connected to the db? (I ask because I don't see a port specified)

    try:

    mongoose.connection.on("open", function(){
      console.log("mongodb is connected!!");
    });
    

    Also, you can do a "show collections" in mongo shell to see the collections within your db - maybe try adding a record via mongoose and see where it ends up?

    From the look of your connection string, you should see the record in the "test" db.

    Hope it helps!

提交回复
热议问题