skip to Main Content

How to lookup a sub-array in mongodb?

I tried to use aggregate and lookup but look like I cannot keep role in the members item. Any idea how to resolve it? db.groups.insertMany([ { title: 'Hi', members: [ { userId: ObjectId('62589515f239750e7e44b958'), role: 'Admin' }, { userId: ObjectId('655f634c632d0c23b9d455de'), role:…

VIEW QUESTION

Javascript – Empty data getting posted in Mongodb database using Node JS html

How to slove this problem Please help me const express=require("express"); const app=express(); const bodyparser=require("body-parser"); const cors=require("cors"); const mongoose=require("mongoose"); const PORT=4000; app.use(cors()); app.use(express.urlencoded({extended:false})); app.use(express.json()); app.use(bodyparser.urlencoded({extended:true})); const URL='mongodb+srv://username:[email protected]/UserDB'; const userSchema=new mongoose.Schema({ name:{ type:String }, password:{ type:String } }); const UserModel= mongoose.model("userData",userSchema); app.get("/",(req,res)=>{…

VIEW QUESTION
Back To Top
Search