Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# mongodb connection

using MongoDB.Driver;
MongoClient client = new MongoClient("mongodb://localhost:27017");
Comment

mongo db connection

const start = async () => {
    
    if (!process.env.DB_URI) {
        throw new Error('auth DB_URI must be defined');
    }
    try {
        await mongoose.connect(process.env.DB_URI!, {
            useNewUrlParser: true,
            useUnifiedTopology: true,
            useCreateIndex: true,
        });
        console.log('Server connected to MongoDb!');
    } catch (err) {
        throw new DbConnectionError();
        console.error(err);
    }

    const PORT = process.env.SERVER_PORT;
    app.listen(PORT, () => {
        console.log(`Server is listening on ${PORT}!!!!!!!!!`);
    });
};

start();
 Run code snippetHide results
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# int to hex 
Csharp :: c# swap variables 
Csharp :: changing euler angles unity 
Csharp :: string length c# 
Csharp :: despicable me 
Csharp :: c# thread sleep vs task delay 
Csharp :: c# linq to dictionary 
Csharp :: best way to compare byte array c# 
Csharp :: bootstrap modal popup 
Csharp :: c# start file 
Csharp :: c# func with no return 
Csharp :: Get Index position of an element in a list in c# 
Csharp :: c# open url 
Csharp :: SAVE FLOAT UNITY 
Csharp :: dynamic convert type c# 
Csharp :: c# how many lines in methods 
Csharp :: c# split a string and return list 
Csharp :: how to pause code execution in c# 
Csharp :: c# datetime remove time 
Csharp :: unity ignore collision between two objects 
Csharp :: how to change a string variables value c# 
Csharp :: convert string to int and read it 
Csharp :: void ontriggerenter not working 
Csharp :: palindrome number c# 
Csharp :: Unity Rigidbody how to set zero momentum 
Csharp :: two variable in one loop c# 
Csharp :: unity log error 
Csharp :: blazor swagger setup 
Csharp :: difference two list c# 
Csharp :: string to biginteger c# 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =