Skip to content
Advertisement

Tag: mongoose

Moongose after find, object.map is not returning key

I have a code that after find and populate, I will then add a new key (‘order_date’) based on createdAt. I have checked with console.log(i.createdAt), it do have the date element in the i, but when I do console.log(orders), it is not retunring me order_date. Is it caused by the async await function? I am doing this because my express

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

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

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