Skip to content
Advertisement

Tag: mongodb

How to find a document with an array of strings based on if it has items in common with a reference array of string?

Given a reference array of strings: [“Comedy”, “Horror”, “Romance”], I would like to query a Movie model with this schema: Such that I will get results where I will get Movies with categories in common with the reference array, sorted by the amount of elements it has in common with the reference array. For example: Note that Movie A is

Blaze template, loop through fields?

I have been unable to find reference to any shortcut that might be available to loop through fields that are named “week01”, “week02”, “week03” where I could reference the field which is an object containing child fields in the same structure. I know of #each for each document but don’t know how to go about each field. I have 30

Mongoose update Sub-Document

How to updating sub-document in mongoose: this is my JSON DATA This is the post Schema. this is the NodeJs part ** I got this response in Postman: post.comments.update is not a function it accept post.update but it’s not what i want because the property message is in the sub-doc of each post object, any help Please ** Answer You

Mongo DB aggregate $lookup slow add index to all documents?

I’ve got two collections in my Mongo DB database. I’m quite new to Mongo DB in general. Each of my collection says that there’s 1 index, now, coming from a Laravel and SQL database where I can improve performance by adding an index with ->index() on my migration for my columns, I assume there’s a way to do something similar

Cast to ObjectID failed – mongoose

Hi I am trying to add an event to a users profile once they click on the event. I am getting the following error – Cast to ObjectId failed for value “{ event: ‘600066640807165d042b91dd’ }” at path “event”. The route for creating a profile and for creating an event work as expected. The 600 is the id of an event

Advertisement