skip to Main Content

Mongodb – NodeJS to Mongo DB Atlas not connecting

I'm new to NodeJS and am having difficulties connecting to Mongo DB atlas. app.js const mongoose = require("mongoose"); const express = require("express"); const app = express(); require("dotenv").config(); mongoose.connect(process.env.DATABASE, { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex:true, }).then(() => { console.log("DB CONNECTED") }).catch(()…

VIEW QUESTION

Mongodb – Given an id of a document with recursive field `children`, find all documents that reference the document or any of its children

I have a collection of product folders productfolders and a collection of products products. const ProductFolderSchema = new Schema( { folderName: { type: String, required: true }, parent: { type: Schema.Types.ObjectId, ref: 'ProductFolder' }, children: [{ type: Schema.Types.ObjectId, ref: 'ProductFolder'…

VIEW QUESTION
Back To Top
Search