Category "mongoose"

Remove certain fields from the mongoose HydratedDocument

When we lean the documents, the id property is still included which is undefined and can cause unexpected errors. To simplify this for my team, I want to remove

Can't populate Mongoose schema on express route

So I want to populate two things and return them in the response, I want to return an array of images and the author. However the response returns nothing, if I

How to remove schema validation in mongoose (mongodb)?

I have MongoDB server version: 5.0.6 installed and used "mongoose": "^6.0.14" to create a model validation. Example of model: const User = new Schema({ name:

NextJS: load global plugin in Mongoose before model creation

I have a folder structure looking something like this root/ pages/ models/ User.js utils/ plugin.js dbConnect.js I want to be able to load th

In mongoose I have executed the example program given in the website but I'm getting the same error that is: TypeError: fluffy.speak is not a function

const mongoose = require('mongoose'); main().catch(err => console.log(err)); async function main() { await mongoose.connect('mongodb://localhost:27017/t

Node js SyntaxError: Unexpected token 'export'

I'm having the following error in the console when I try to run my api written in node js. Can you tell me which is the problem.

Getting error: The expression is not callable Mongoose NextJS

I trying to save data to a mongoose model on NextJS page. I get a typescript error on this line: await User.create(data) This expression is not callable. Each

I can't call PATCH method using Pug, Mongoose and Express.js

I am new to code and I apologize in advance for all my noob mistakes. I'm trying to set a new color to an existing object stored in MongoDB using the PATCH meth

How to query mongoDB with mongoose without having a model

so i want to query my mongo DB without using a model, let me preface this by saying, i am looking for options other than using the mongodb driver. so in one app

MongooseError: Operation 'featureds.find()` buffering timed out after 10000ms

I have a collection on MongoDB from which I'm trying to query all the elements using find(): const mongoose = require('mongoose'); const Featured = mongoose.mod

Method expression is not of Function type (mongoose Model)

i came across this error today and did not find a fix for it. const mongoose = require('mongoose'); const userSchema = mongoose.Schema({ name: {type:St

Unwind object array but preserve its parent

I want to unwind some data, but preserve the parent. I am getting the whole flattened objects, but missing the first one. I want to keep that one. How can I do

Node/JS mongoose REST API How to push a new object into a nested array of objects all in one collection

Noob MERN Stack Dev here, I am building a little food delivery practice web app. I have begun creating a basic RESTful API to serve my food delivery site. I am

How to solve Mongoose v5.11.0 model.find() error: Operation `products.find()` buffering timed out after 10000ms"

How to solve model.find() function produces "buffering timed out after ... ms"? I'm using mongoose v 5.11.0, npm v6.14.8 and mongodb v Here's the code. var expr

TypeError: (0 , _expressGraphql2.default) is not a function

Trying to create a server for my application using graphQL server, but keep getting the error below. I have tried debugging with similar issues on this site but

How to display subdocuments on frontend i am using mongodb as the database

This is the front end. I have made some changes you can check out my repo if anyone has any answer to this it'll be great use i think there is there a way to li

mongoDb - How do I delete an object from a nested array

"ProductCategory": [ { "_id": "6246e0d09b16cf549256ed75", "name": "Arduino Boards", "desc": "this is for demo purpose"

Remove generated string from Mongoose schema with custom validation

I have a schema with a custom validation. const schema = new mongoose.Schema({ username: { type: String, required: true, validate: {

How to get decrypted values in the aggregation result by the using of getter and setter in node.js

var mongoose = require("mongoose"); const Schema = mongoose.Schema; let CryptoJS = require("crypto-js"); function encrypt(text) { try { let ciphertext =

Mongoose and MongoDB - Get all countries and users associated with country

So I have a list of posts data that looks like this: [ {user: 'Bob', country: 'USA'} {user: 'Kim', country: 'Mexico'} {user: 'Darren', country: 'Mexico'}