I just started learning Node.js. The idea of this small application is to use express and mongosse to store some users in a based cloud database (mongoDB via mlab). I have two seperate files : User.js (models/User.js) var mongoose = require('mongoose'); module.exports = mongoose.model('User', ...
Discy Latest Questions
I am trying to create a fullstack app reading the following tutorial: https://medium.com/javascript-in-plain-english/full-stack-mongodb-react-node-js-express-js-in-one-simple-app-6cc8ed6de274 I followed all steps and then tried to run: node server.js But I got the following error: MongoDB connection error: MongoTimeoutError: Server selection timed out after 30000 ms
So I’m currently wirting a web application and I need database so I decided to go with mongodb and mongoose. Until now I tested everything on localhost and it worked but I wanted to move the data to a server. ...
I have server.js and db.js The db.js file interacts with my database using Mongoose and I use server.js to call functions from db.js : var mongoose = require('mongoose'); mongoose.connect('', { useNewUrlParser: true }) var Schema = mongoose.Schema; module.exports = function () { ...
How can I use aggregate and find together in Mongoose? i.e I have the following schema: const schema = new Mongoose.Schema({ created: { type: Date, default: Date.now() }, name: { type: String, default: 'development' } followers: ...
I’m trying to connect to my mongoDB server via the connection string given to me by mongo: "mongodb+srv://david:[email protected]/test?retryWrites=true" In my code I am calling the connection through mongoose like this (obviously putting in my password): const mongoose = require('mongoose'); const db = ...
I’m facing this weird issue in NodeJS when using with Passport.js, Express and Mongoose. Basically, I get an error saying “Cannot set headers after they are sent to the client” even though I don’t send more than one header. I’ve read ...
I am using mongoose findOneAndUpdate but still getting the error, DeprecationWarning: collection.findAndModify is deprecated. Use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead. But I am not even using findAndModify, why is it converting my query to findAndModify?