gpt4 book ai didi

javascript - 在 JavaScript 对象中设置默认值?

转载 作者:行者123 更新时间:2023-11-30 21:05:49 24 4
gpt4 key购买 nike

这项工作会说一个新用户注册该网站,我希望默认 Angular 色是“用户”吗?

我希望当一个人注册时,默认 Angular 色设置为“用户”,并且可以稍后将其更改为“管理员”。

  firstName: {
type: String,
required: true
},
lastName: {
type: String,
required: true
},
dob: {
type: Date,
required: true
},
email: {
type: String,
required: true
},
username: {
type: String,
required: true
},
password: {
type: String,
required: true
},
role: {
type: String,
default:
}
});

最佳答案

这是某种Schema (Mongoose) 如果是,那么是的,它会起作用。

关于javascript - 在 JavaScript 对象中设置默认值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46625059/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com