Category "mongoose"

Set mongoose schema with changing fields

I want to make a mongoose schema that will append timeseries data. I got the idea for that model after reading this (https://www.mongodb.com/blog/post/schema-de

Which relation in MongoDB is better?

For my whole projects I have relationed my multiple collection as this. User model Name:string, email:string, password:string, vehicles:[{ "vehicleId", "vehi

How to upsert object in Mongoose Array?

I want to edit an array with mongoose, if the object id already exist in the array, then it will create a new one, and if it exist, it will update. My code: con

ReferenceError: "_" is not defined

recipe = new Recipe(_.pick(req.body, ['name', 'tag', 'recipe'])); await recipe.save(); }); error: recipe = new Recipe(_.pick(req.body, ['name', 'tag

Populate Failed immediately a ref was indexed in Mongodb via Mongoose Schema

I had a Post Model with a ref as below const mongoose = require("mongoose"); const PostSchema = new mongoose.Schema( { _id: mongoose.Schema.Types.O

How to get mongo documents created in the last 24 hours using mongoose?

I have this mongoose schema const PictureSchema = mongoose.Schema({ user: { type: mongoose.Schema.Types.ObjectId, ref: 'User', requi

Edit value for a key in a Map in Angular

I have a model that uses a Map for eg: (I also have other properties such as Name) export class User { _id!: string; accounts!: Map<String,Number>

Modifying Schema only for one document

I'm creating an application in the MERN stack and I stumbled upon a problem. I will start by explaining how that app is going to work. So, in that application u

How to 'join' or populate an array

Here is my very basic product schema: const productSchema = new Schema({ productName: { type: String, required: true, }, productDescription: {

Unexpected token ')' in D:\Mridul\Codes\js\API BASED\Anime Quote\views\info.ejs while compiling ejs

So I want to display MongoDB data in HTML so I used the EJS template but this is the error it is showing . I can't seem to figure out where the problem is, IS i

Express routes working with url params but not with specific sub routes

I'm building an API for my web app and I was able to successfully send requests to the routes in Post.js when they only had url params. But when I try to create

mongoose save internal documents creating a document that contains a document

Im learning mongoose and i have a question how to save several documents: // Product.js const categorySchema = mongoose.Schema( { name: String }, { collecti

Mongoose - "Enriched" Query with Data from other Collection

I'm quite new to using Mongoose and therefore not too familiar with operations that go beyond finding data in a single collection. Was googling approaches to ac

How to update and delete a review of a product using nodejs

I am creating a e-commerce app and now I want to update and delete a review of a product using nodejs and database is mongoDB (using mongoose). This is my User

Nest JS Circular Dependency Issue - Mongoose Module

I am trying to inject dependencies in mongoose module for root async. I want to kind of simulate a cascade delete using mongoose hooks. I have this module, whic

Update objects with findOneAndUpdate by similar object value

I am trying to update documents values, if they already exist in a collection, if they have the same value for a specific object key. For example, I have the fo

MongoDB, get documents by a field, and mergeObject from another collections grouped count

Okay, the title is a bit too verbose and complicated but I have no idea how to put it any better. So here's what I have ModelA ModelB that has reference to Mode

Error while reloading nextjs server while using mongoose [duplicate]

I am using NextJS as my framework along with Mongoose. I have seen a few tutorials to implement caching for Mongoose but everytime I make some

graphql mutation giving error while creating record

here is my scheme, I wasnt to create one record so when i am passing field in graphql it is showing error const { BookTC } = require("../model/book"); const { B

Schema for saving a lot of questions MongoDb

If I have a survey application for child tracking what is the best way to save survey questions in MongoDB? Knowing that survey is divided into stages (about 12