我正在处理我的项目,我有一个与mongoose schema属性相关的问题。
以下是当前代码:
const CURRENCY = "EUR", "USD", "GBP";
let Salary = new Schema
({
currency: { type: String, enum: CURRENCY, required: true },
amount: number
});
问题是:如果我(也许)想要扩展此列表,哪种方式更好?使用上面的枚举或使用包含货币的其他架构?
像:
let Currency = new Schema
({
currencyType: { type: String },
});
let Salary = new Schema
({
currency: { type: mongoose.Schema.Types.ObjectId, ref: 'Currency' },
amount: Number
});
是否经常只使用一个属性创建架构?
感谢您的帮助。