What is the difference between MongoDB and Mongoose query statements?

  mongodb, question

MongoDB can write like this

db.getCollection('users').find({})

Or ..

db.users.find({})

HeredbWhat is it and how should it be defined in the code?

In mongoose, it is usually written like this:

var User = require('../models/user')
 User.find({})

How should it be defined in mongoosedbCan also write

db.users.find({})

This way of writing?

(⊙ o ⊙o⊙)… … look at the wood in front of your code.

var mongoose = require('mongoose');
 var db = mongoose.connect('mongodb://localhost/tasks');

Such code?dbIn fact, it is a connection instance of mongoose.

And yoursUserIs it a Model? 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);

So you can use:

User.find({});