mongodbmongoosetypesschemaobjectid

what does mongoose.Schema.Types.ObjectId do


what does this piece of code do?

 type: mongoose.Schema.Types.ObjectId,
    ref: "Role"

I didn't get what happens with the mongoose.Schema.Types.ObjectId what does it do?


Solution

  • Its just a schema type in mongoose
    It is used as a primary key
    and the ref means that you have kept a reference of another model's document by using its primary key