我目前正在运行代码:
export class SystemInformationContent {
createdAt: number;
createdBy: User | mongoose.Schema.Types.ObjectId | null;
updatedAt?: number;
updatedBy?: User | mongoose.Schema.Types.ObjectId | null;
}
@Schema()
export class SystemInformation {
@Prop(
raw({
createdAt: { type: Number, required: true },
createdBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
updatedAt: { type: Number, default: 0 },
updatedBy: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User',
default: null,
},
}),
)
system: SystemInformationContent;
}
Run Code Online (Sandbox Code Playgroud)
我没有找到任何“扩展”模式的方法SystemInformationContent,因此raw()在装饰器中使用了该函数@Prop(),但我想知道是否有办法做这样的事情:
export class SystemInformationContent {
@Prop({ required: true })
createdAt: …Run Code Online (Sandbox Code Playgroud)