This commit is contained in:
Primakov Alexandr Alexandrovich
2025-05-08 15:48:02 +03:00
parent 48167530fd
commit 95bcaf3c5e
3 changed files with 13 additions and 9 deletions

View File

@@ -2,7 +2,3 @@ import 'dotenv/config';
// Connection URL // Connection URL
export const mongoUrl = process.env.MONGO_ADDR export const mongoUrl = process.env.MONGO_ADDR
console.log('=======================================================')
console.log('mongoUrl', mongoUrl)
console.log('=======================================================')

View File

@@ -1,15 +1,18 @@
const MDBClient = require('mongodb').MongoClient import { MongoClient as MDBClient } from 'mongodb'
const { mongoUrl } = require('./const') import { mongoUrl } from './const'
const dbInstanses = { const dbInstanses = {
} }
console.log('=======================================================')
console.log('mongoUrl', mongoUrl)
console.log('=======================================================')
const mongoDBConnect = async () => { const mongoDBConnect = async () => {
try { try {
const MongoClient = new MDBClient(mongoUrl, { const MongoClient = new MDBClient(mongoUrl, {})
useUnifiedTopology: true,
})
const client = await MongoClient.connect() const client = await MongoClient.connect()
console.log('Подключение к MongoDB успешно') console.log('Подключение к MongoDB успешно')
return client return client

View File

@@ -2,6 +2,11 @@ import mongoose from 'mongoose'
import { mongoUrl } from './const' import { mongoUrl } from './const'
console.log('=======================================================')
console.log('mongoUrl2', mongoUrl)
console.log('=======================================================')
mongoose.connect(`${mongoUrl}`).then(() => { mongoose.connect(`${mongoUrl}`).then(() => {
console.log('Подключение к MongoDB успешно') console.log('Подключение к MongoDB успешно')
}).catch((err) => { }).catch((err) => {