skip to Main Content

nodejs mongodb aggregation not working properly

I have this type of MongoDB collection { "uploaded_video": [ { "_id": "622a03e66d59f72b72358069", "user_id": "Ec3FNhk45Lh1xk92cO9eoXDiWEk2", "uploaded_video": { "_id": "622a0616242e5b2e65e8b3b4", "video_description": "test", "created_At": "2022-03-10T14:05:29.000Z", "recordedVideo": false, "thumbnailCreated": true }, "activityType": "uploaded_video" } ], "comment_video": [ { "_id": "622a03e66d59f72b72358069", "user_id": "Ec3FNhk45Lh1xk92cO9eoXDiWEk2", "comment_video":…

VIEW QUESTION

Select distinct combination of two fields with a condition in MongoDB (Node JS)

I have this kind of collection named 'Message' [ { _id: new ObjectId("62641aea1fbe19349f8fba78"), text: 'Hello', user: new ObjectId("625b8f00e2464fb758263b4d"), receiver: new ObjectId("62638d3e5bcd98e7e48ca1b7"), createdAt: 2022-04-23T15:27:38.270Z, updatedAt: 2022-04-23T15:27:38.270Z, __v: 0 }, { _id: new ObjectId("6264256fc0ee5093f8d994a0"), text: 'Hi', user: new ObjectId("62638f1495b841266161b032"), receiver: new ObjectId("62638d3e5bcd98e7e48ca1b7"),…

VIEW QUESTION

Mongodb – Express router is not working on mongoose. It is saying User is not defined

**App.js Code** const express = require("express"); const { default: mongoose } = require("mongoose"); const gaming = require("./routes/gaming"); const app = express(); app.use(express.json()); app.use("/", gaming); const dbConnect = mongoose.connect("mongodb://localhost:27017/Gaming"); const mySchema = new mongoose.Schema({ name: String, genre: String, games: String, })…

VIEW QUESTION

Mongoose aggregate query working as a mongodb query but not able to convert to mongoose

Below is my JSON structure [{ "_id" : ObjectId("626204345ae3d8ec53ef41ee"), "categoryName" : "Test Cate", "__v" : 0, "createdAt" : ISODate("2022-04-22T01:26:11.627Z"), "items" : [ { "itemName" : "Cate", "user" : ObjectId("6260729af547915d9d876c23"), "itemDescription" : "slkkndanslk", "itemImage" : "/images/camping-table.jpeg", "_id" : ObjectId("626204339b24b2ead6c05a70"), "updatedAt" :…

VIEW QUESTION
Back To Top
Search