What do you want to save?
Add Code snippet
New code examples
-
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 -
Shell/Bash 2021-11-14 05:27:10
how to install mongoose globally
$ npm install mongoose Add solution