What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-01-22 12:15:02
mern stack delete
//MERN STACK DELETE //Route import { deletePost } from "../controllers/posts.js" router.delete("./:id", deletePost) //Controller export const deletePost = async (req, res) => { const { id } = req.params; if (!mongoose.Types.O... Add solution -
Javascript 2022-01-22 02:00:14
DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor
mongoose.connect(mongoConnectionString, {useNewUrlParser: true, useUnifiedTopology: true}); Add solution -
Javascript 2021-11-21 13:30:35
mongoose connect to URL of atals
try { mongoose.connect(MONGODB_URI || 'mongodb://localhost/YOUR_DB_NAME', { useNewUrlParser: true, useUnifiedTopology: true }, () => console.log("connected")); } catch (error) { console.log("could not connect"... Add solution -
Javascript 2021-11-20 18:44:23
How to connect mongoDB using mongoose
import mongoose from 'mongoose' export const connectDb = async () => { try { await mongoose.connect('mongodb://localhost:27017/test', { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true, }) } catch (er... Add solution -
Javascript 2021-11-17 19:14:11
how to connect to mongoose and create a model
const express = require('express'); const app = express(); const mongoose = require('mongoose'); const bodyParser = require('body-parser'); app.use(bodyParser.json()); const PORT = process.env.PORT || 3000; //connecting to db try { mongoose.conne... Add solution -
Other 2021-11-14 12:06:11
findmany mongoose or find by multiple Ids
model.find({ '_id': { $in: [ mongoose.Types.ObjectId('4ed3ede8844f0f351100000c'), mongoose.Types.ObjectId('4ed3f117a844e0471100000d'), mongoose.Types.ObjectId('4ed3f18132f50c491100000e') ]} }, function(err, docs){ con... Add solution