var test = res[0]._id.toHexString(); // получаем hex-строку require("mongoose").Types.ObjectId(test); // получаем ObjectId 

When I call ObjectId, I get an error: Type error: hex is not a function.

  • What is the cause of the error: “Hex is not a function?” - oddly enough, the fact that hex is not a function. - Grundy
  • require ("mongoose"). Types.ObjectId (test); // we receive ObjectId - check in the help what exactly can be transferred to this function, and what you transfer. - Grundy
  • @Grundy There take a string (hex-string) - Urukhay

0