Closed mako4kamiya closed 3 years ago
module.exports = mongoose => {
const Role = mongoose.model(
"role",
mongoose.Schema(
{
name: String
})
);
return Role;
};
これと
const mongoose = require("mongoose");
const Role = mongoose.model(
"Role",
new mongoose.Schema({
name: String
})
);
module.exports = Role;
これの違いはなんだ。。。
module.exports = mongoose => {
const User = mongoose.model(
"User",
mongoose.Schema(
{
name: String,
password: String,
roles: [
{
type: mongoose.Schema.Types.ObjectId,
ref: "Role"
}
]},
{ timestamps: true }
)
);
return User;
};
Roleオブジェクトを参照する
jsonwebtoken bcryptjs追加