'Confused about Types.ObjectId and Schema.Types.ObjectId from Mongoose

I'm trying to created nested schema with mongoose, attaching a user_id field for subdocuments. I found out this approach

const {Schema} = require("mongoose");
var user_id = {
    type:Schema.Types.ObjectId,
    ref:"User",
  },

but later i found that Types can be imported from mongoose on top level , but the definition of the ObjectId is very different from Schema.Types, as such

const {Types} = require("mongoose");
var user_id = {
    type:new Types.ObjectId(),
    ref:"User",
  },

I couldn't find documentation on this nuance....I guess i should use a consistent approach across the app, so can someone help to explain?

*Edit: I think the one I should use should be consistent with the way _id is defined for the User table, but which one was it used?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source