0
var id = new mongodb.ObjectID("545e2fa90293a69004414ae9");
var valid = ObjectID.isValid(id);

Why do I get this value it - T^/©¦AJé"?

Help me please!

1
  • 1
    Can you provide more information on the code that is not working. What variable returns the value?
    – ooo
    Nov 8, 2014 at 17:35

1 Answer 1

0

Currently the isValid() function expects either a number or a string (12 or 24 characters). You are passing it an object, that's why it returns false. You need to convert the ObjectId object to a string:

var valid = ObjectID.isValid(id.toString());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.