logo
Search
showing results for - "convert string or string array to object mongoose object id"
Roberto
08 Oct 2019
1function toObjectId(ids) {
2
3    if (ids.constructor === Array) {
4        return ids.map(mongoose.Types.ObjectId);
5    }
6
7    return mongoose.Types.ObjectId(ids);
8}
9
similar questions
array of objects to objectconvert string array to objectid mongoosemongo query by object id node jstypegoose array of stringsmongoose query using an arryjavascript array with objects to stringmongoose response to objecthow to query array of object in mongoosconvert array object to string javascriptget plain object instead of mongoose document in query 3fadd an object to an array mongossemongoose id from string
queries leading to this page
convert object to string in mongoose idmongoose cast array of string to objectidmongoose convert array objectid to stringconvert string or string array to object mongoose object id
privacy policyterms of useinstagram
Crafted with  ♥  for everyone

sign in to continue
your answer for
you will get a confirmation link on this - you will have to click that for successful submission of your answer. we require this to keep the website free of spam, bots and unhelpful content
please ensure to add code which is syntactically corrent and executes properly
sign in to continue
ask question on maxinterview
you will get a confirmation link on this - you will have to click that for successful submission of your question. we require this to keep the website free of spam, bots and unhelpful content
please be clear, to the point and respectful
sign in to continue