When I use mongoose.connection, models are connected directly with the unique connection. In this case db1 is only used for quering (not model require). But db2 use 2 models. ¿How Can I connect those models with db2 only?
Thanks for helping
const db1 = mongoose.createConnection("atlasuri").asPromise()
const db2 = mongoose.createConnection("localuri").asPromise()
app.get("/",async(req,res)=>{
const finded = (await db1).collection("users")
await finded.forEach(el=> console.log(el))
res.json(finded)
})
Models
const Criterion1=new mongoose.model('Criterion',new mongoose.Schema({
name:string
}));
const User=new mongoose.model('Criterion',new mongoose.Schema({
name:string
}));