Category "mongoose-schema"

How can Add two different field which type is ObjectId in same object which refer same schema

const ChatSchema = new mongoose.Schema({ username: { type: String, }, mobile: { type: Number, }, friends: [ { type: mongoose.Schema.

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

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

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): AssertionError [ERR_ASSERTION]

I have the following setup in Visual Studio Code for nodejs project: Model: genre.js const Joi = require('joi'); const mongoose = require('mongoose'); const

Not able to add more than 1 post request in the mongo db

i am using mongo db to fetch and post the data but unable to post more than 1 request here is my code ON posting the different values second time i am getting t

Find by _id on an array of objects in mongodb database

I'm trying to find the id of an object inside an array of objects. That _id has the same field name _id as others in the document. This is my model (brief) var

How do I determine the order of "properties" with swagger-autogen in node.js?

For some reason, swagger-autogen is reversing the order of my properties in my swagger.json output file. For example, I have a simple 'user' mongoose schema set

mongoose Model.create function returns undefined

The above query returns a 200 when I try to create a User, but whenever I log into MongoDB there is no collections created. Can anyone help ? //user model co

Mongoose - remove multiple documents in one function call

In documentation there's deleteMany() method Character.deleteMany({ name: /Stark/, age: { $gte: 18 } }, function (err) {}); I want to remove multiple documents