Answers for "convert string or string array to object mongoose object id"

0

convert string or string array to object mongoose object id

function toObjectId(ids) {

    if (ids.constructor === Array) {
        return ids.map(mongoose.Types.ObjectId);
    }

    return mongoose.Types.ObjectId(ids);
}
Posted by: Guest on August-16-2021

Code answers related to "convert string or string array to object mongoose object id"

Code answers related to "Javascript"

Browse Popular Code Answers by Language