Muhammad Ali
Muhammad Ali

Reputation: 369

mongoose match values and update query

I have an array like

const names = ["mike","alice","jesse"];

i have document

{

"name":"alice", // could be any name
"age":17,
"occupation":"engineer",

}

now I want to match names from array and if they match then I update the document. I have quite long array and more than 500 documents.

Upvotes: 0

Views: 72

Answers (1)

Pardeep Baboria
Pardeep Baboria

Reputation: 468

you may try this if names array is to big.

if(names. indexof(incoming_name) > -1){ //update query with where name:incoming_name }

Upvotes: 1

Related Questions