Answers for "mongoose check if string is objectid"

0

mongoose check if string is objectid

var ObjectId = require('mongoose').Types.ObjectId;
ObjectId.isValid('microsoft123'); //true
ObjectId.isValid('timtomtamted'); //true
ObjectId.isValid('551137c2f9e1fac808a5f572'); //true
Posted by: Guest on June-21-2021
0

js validate mongodb id

//Validate MongoDB ID
const oid = 'abcd56789012345678901234'
return oid.length === 24 &&  !isNaN(Number('0x' + oid))
Posted by: Guest on January-26-2021
0

mongoose check if string is objectid

new ObjectId('timtamtomted'); //616273656e6365576f726b73
new ObjectId('537eed02ed345b2e039652d2') //537eed02ed345b2e039652d2
Posted by: Guest on June-21-2021

Code answers related to "mongoose check if string is objectid"

Browse Popular Code Answers by Language