nodejs 连接 mongoDB 查询数据总返回[]
nodejs
------
app.post('/GetMail', function (req, res) {
Models.MAIL.find((err, items) => {
console.log(items)
})
})
db.js
-----
const mongoose = require('mongoose')
mongoose.connect('mongodb://localhost:27017/abc', { useNewUrlParser: true }, (err, db) => {
console.log(db);
if (err) {
console.log('********** [数据库连接失败] **********')
} else {
console.log('********** [数据库连接成功] **********')
}
})
const mail = new mongoose.Schema({
code: Number,
},
{
collection: 'mail'
})
const Models = {
MAIL: mongoose.model('mail', mail),
}
module.exports = Models
mongoDB
-----
数据库名字为 abc
下面有 mail => 20220602
想指定查询'20220602'表数据 总返回空呢