Open Ena-Heleneto opened 1 week ago
you can use defineMongooseConnection to create connection
Sorry, I don't quite understand. I want to establish a persistent database connection. Where should I execute it? like this?
//utils/db.util.ts
import { defineMongooseConnection } from '#nuxt/mongoose'
export const connection01 = defineMongooseConnection({ uri: 'mongodb://127.0.0.1/nuxt-mongoose01' })
export const connection02 = defineMongooseConnection({ uri: 'mongodb://127.0.0.1/nuxt-mongoose02' })
//nuxt.config.ts ~note or delete
// mongoose: {
// uri: 'mongodb://root:root%4012138@8.219.6.234:27017/',
// options: {},
// modelsDir: 'models',
// devtools: true,
// },
Will this create a new database connection each time it's called?
Or I think the multi-connection configuration method in NestJS is quite good, maybe can use it as a reference. https://docs.nestjs.com/techniques/mongodb#multiple-databases
Hello,My project needs to connect to multiple databases simultaneously. Is there a way to quickly create multiple connections?