Answers for "jest mongoose multiple connections"

1

jest mongoose multiple connections

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!)
Posted by: Guest on July-01-2021

Code answers related to "jest mongoose multiple connections"

Code answers related to "Javascript"

Browse Popular Code Answers by Language