我正在为 mongoose 数据库建模,需要解决一些问题。这是我们的业务规则和模型架构:
const userSchema = new Schema(
{
email: { type: String, required: true, unique: true},
password: {type: String, required: true}
}
const gatewaySchema = new Schema(
{
idGateway: { type: String, unique: true },
name: String,
}
const gatewayInfoSchema = new Schema(
{
user: { type: Schema.Types.ObjectId, ref: 'User' },
gateway: { type: Schema.Types.ObjectId, ref: 'Gateway' },
active: Boolean,
keys: { pub: String, priv: String },
methods: [{
method: String,
active: Boolean
}]
}
// user - gateway combination is unique
问题是:
感谢您的帮助。