其他分享
首页 > 其他分享> > mongoose

mongoose

作者:互联网

const mongoose = require('mongoose');

const options = {
 host: "159.75.22.82",
 port: "27017",
 db_name: "xxx",
 user: "xxx",
 pass: "xxx",
};

const url = `mongodb://${options.user}:${options.pass}@${options.host}:${options.port}/${options.db_name}`;

// useUnifiedTopology: true,
const MongoClientConfig = {
  dbName: 'uglyTuan'
};

mongoose.connect(url, MongoClientConfig).then(err => {
  // console.log('err', err);
})

const Com = mongoose.model('comment', new mongoose.Schema(), "comment");

console.log("COM:", Com.find((err, res) => {
  console.log(err, res)
}))

在这里插入图片描述

标签:const,log,err,xxx,mongoose,options
来源: https://blog.csdn.net/printf_hello/article/details/121003170