Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

connect mongoose to atlas

const mongoAtlasUri =
  "mongodb+srv://username@gmail.com:password@cluster0.mkb94.mongodb.net/DB_NAme?retryWrites=true&w=majority";

try {
  // Connect to the MongoDB cluster
  mongoose.connect(
    mongoAtlasUri,
    { useNewUrlParser: true, useUnifiedTopology: true },
    () => console.log(" Mongoose is connected")
  );
} catch (e) {
  console.log("could not connect");
}
Comment

mongoose connect to mongodb

// local conecation

const mongoose = require("mongoose");

mongoose
  .connect("mongodb://localhost:27017/testdb")
  .then(() => console.log("Connected to MongoDB..."))
  .catch((err) => console.error("Could not connect to MongoDB...", err));
Comment

connect mongoose to atlas

const mongoAtlasUri =
  "mongodb+srv://username@gmail.com:password@cluster0.mkb94.mongodb.net/DB_NAme?retryWrites=true&w=majority";

try {
  // Connect to the MongoDB cluster
  mongoose.connect(
    mongoAtlasUri,
    { useNewUrlParser: true, useUnifiedTopology: true },
    () => console.log(" Mongoose is connected")
  );
} catch (e) {
  console.log("could not connect");
}
Comment

mongoose connect to mongodb

// local conecation

const mongoose = require("mongoose");

mongoose
  .connect("mongodb://localhost:27017/testdb")
  .then(() => console.log("Connected to MongoDB..."))
  .catch((err) => console.error("Could not connect to MongoDB...", err));
Comment

PREVIOUS NEXT
Code Example
Javascript :: iterate through an array 
Javascript :: how to clone an object 
Javascript :: js bitwise operators 
Javascript :: int to string javascript 
Javascript :: fatorial recursivo em javascript 
Javascript :: immediately invoked function expression 
Javascript :: javascript image to variable 
Javascript :: forof 
Javascript :: get last index of array of objects javascript 
Javascript :: javascript NEGATIVE_INFINITY 
Javascript :: return object list in find js 
Javascript :: jquery number format thousand k 
Javascript :: react state value not updating in function 
Javascript :: getelementbyid js 
Javascript :: accessing via name jquery 
Javascript :: insert element at beginning of array javascript 
Javascript :: Sort an array to have specific items 
Javascript :: jwt expiresin 
Javascript :: javascript get page args 
Javascript :: javascript foreach break 
Javascript :: usecallback 
Javascript :: jquery get all classes of a div 
Javascript :: find smallest length string in an array js 
Javascript :: slice string js 
Javascript :: discord.js get user by username 
Javascript :: length of list in javascript 
Javascript :: how to destroy a computer using javascript 
Javascript :: deploy react app 
Javascript :: TYPING TEXT USING JS 
Javascript :: gsheet query select remove header 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =