📌  相关文章
📜  jest mongoose 多个连接 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:19.431000             🧑  作者: Mango

代码示例1
import mongoose from 'mongoose';

const opts = { useMongoClient: true }; // remove this option if you use mongoose 5 and above
const conn = mongoose.createConnection(); // just create connection instance
const User = conn.model('User', new mongoose.Schema({ name: String })); // define model
conn.open(uri, opts); // open connection to database (NOT `connect` method!)