'Attribute from Model1 as Attribute for Model2

User Model:

const UserSchema = mongoose.Schema({
    userID: { type: String, unique: true },
    userName: String,
    password: String,
    isAdministrator: { type: Boolean, default: false }
});

ForumThread Model:

const ForumThreadSchema = mongoose.Schema({
    name: String,
    description: String,
    ownerID: //USERID FROM USER MODEL
});

Question: How can i use the userID from my User Model as the type from ownerID in ForumThread Model?



Sources

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

Source: Stack Overflow

Solution Source