Nodejs uses mongoose to operate mongodb

connecting to the database ok, is sure to be connected, but when manipulating a collection, the collection is not automatically created in the database when the collection does not exist. I remember that the document said that it would be automatically created when it did not exist.

Apr.22,2021

is created, maybe you should save something to try


the collection is automatically created only when the insert operation is performed. New mongoose.Schema ({}) is not really an insert operation yet, it's just defined.


try saving a piece of data? The collection is not displayed if there is no data in the collection. (at least none of the tools I use are displayed.)


does anyone know what's going on?

Menu