(⊙o⊙)… Look at the front of your code to see if there is anything
var mongoose = require('mongoose');
var db = mongoose.connect('mongodb://localhost/tasks');
Such a code? dbIn fact, it is a mongoose connection instance.
And yours User comes from a Model, right? Your code should look something like this:
var mongoose = require('mongoose');
var db = mongoose.connect('mongodb://localhost/tasks');
var schema = new mongoose.Schema({
name: String,
path: String
});
module.exports = mongoose.model('User', schema);
(⊙o⊙)… Look at the front of your code to see if there is anything
Such a code?
db
In fact, it is a mongoose connection instance.And yours
User
comes from a Model, right? Your code should look something like this:So you can use:
db is the database operation object of the current operation, which refers to the database switched to using use db
It should be like what was said above. Your model file is written like the above. In this case, it can only be written like the following.
But if you use mongoose, you have to write it as db.users.find({}), you can change it in the model file: