Category "mongoose"

Property 'create' does not exist on type { new (fileBits: BlobPart[], fileName: string, options?: FilePropertyBag | undefined):File; prototype: File}

I'm trying to create a file-sharing app using Multer, Cloudinary, Typescript, and Mongoose. When I'm trying to save the files uploaded by users and the data lik

Use Schema inside another Schema not working. Error: CastError: Cast to [ObjectId] failed for value

What I'm trying to achieve: Use one Schema (Ingredient Schema) inside another one (Recipe Schema). My goal is that in the Recipe Schema, my ingredients key to b

Remove specific object from array during aggregation

I have documents with the following structure: {field: ["id1", "id3"]}, {field: ["id2", "id1"]} To query the documents I use aggregate({$match: {'field' : { $i

login with email or phone or username in node js

How can I login email or phone or username with password in node js and mongodb? user can login with email and password, username and password, phone and passwo

grammar & spell checking in nodejs

How to check spelling mistakes, grammar & punctuation errors, use of greetings & short keywords and total time to complete each single chat session in s

Mongodb insert null date

Mail Schema: var mail = new mongoose.Schema({ globalId: {type: String, index: true, unique: true}, from: {type: String, required: true}, beginDate:

Javascript await / promise order of execution is not as expected

In my Nodejs project I would just like to await a mongoose.save function before continuing with my code. The below example does not work, but can anyone help me

ERR_HTTP_HEADERS_SENT: Cannot set headers after they are sent to the client

I'm facing this weird issue in NodeJS when using with Passport.js, Express and Mongoose. Basically, I get an error saying "Cannot set headers after they are sen

findOneAndUpdate is not a function of mongoose

I know this question has been answered before but I can't seem to implement the changes into what im working with. I'm trying to create a daily command that rew

How can I solve this problem with mongoose connection?

This code worked for a while and I don't know what I did but it gives me this error. I saw a some guys said that update the Node, but it doesn't work for me. Mi

Get trending groups using mongodb aggregation

I have two collections, Group and GroupChat. A group has a chatroom respectively. // group.model { name: string, desc: string } // group.chat.model { group:

Subdocument not being saved in its own collection - Mongoose

I found this on the documentation for mongoose: Subdocuments have save and validate middleware just like top-level documents. Calling save() on the parent docu

Delete object from inner schema in mongoose?

How do I delete object from inner schema in mongoose? I try to delete comments from the Holiday Schema, this is the holiday schema: const holidaySchema = new mo

Increment value in update query mongoDB

I am trying to add two values in a mongoose function. This the function im using: Equipa.findOne({ '_id': req.params.equipaID }, function (error, equipa) {

node.js moongose find populate cant access to array

I have this in my backend: ad = await Ad.find({'company': companyId}).populate('creator'); And when i console.log(ad) i get this: [ { connections: [],

mongoose | batch insert and update if already exists

I have the following Schema const domain = new Schema({ created: { type: Date, default: Date.now }, last_update: { type: Date, default: Date.now }, do

mongoose | batch insert and update if already exists

I have the following Schema const domain = new Schema({ created: { type: Date, default: Date.now }, last_update: { type: Date, default: Date.now }, do

MongoDB Atlas very slow connection on hot reload

I have been working on a React application that would connect to MongoDB Atlas with Mongoose. Using nodemon and webpack for hot reloading it would reconnect to

MongoDB indexes are ignored inside the $facet pipeline

I have all combination of compound indexes for this collection. The aggregattion query i used is: db.products.aggregate( [ { $facet: { "categ

Mongoose 5.11.11 SchemaDefinition Typing

Mongoose recently updated to accept a model generic it works well with a string type but not with a boolean type. Type 'boolean' is not assignable to type 'Sche