Skip to content
Advertisement

Tag: mongodb-query

MongoDb update with ElemMatch

I have a collection that has document structure like following: Mongo PlayGround As you can see, each document has basicDetails object and a tasks array. Each task contains some properties of its own and a subtasks array. I want to update subtasks’s description from ABC to XYZ where root level id is 1, task’id is 10 and subTasks.id =120 How

Add field not in schema with mongoose

I am trying to add a new field to a document, but this isn’t working: Creating my UserModel prototype: Then calling it This successfully updates any field as long as it exists, but it won’t add any new one. Answer You can add and remove fields in schema using option { strict: false } option: strict The strict option, (enabled

Mongoose find/update subdocument

I have the following schemas for the document Folder: So, for each Page I can have many permissions. In my CMS there’s a panel where I list all the folders and their permissions. The admin can edit a single permission and save it. I could easily save the whole Folder document with its permissions array, where only one permission was

Advertisement