如何使objectId归档为唯一。在add_to_cart_user
的架构中,我尝试过这样的unique=true
,但它不起作用。
schemaDefinition = {
add_to_cart_user: {
type: ObjectId,
unique: true,
required: [true, 'add_to_cart_user is required'],
},
add_to_cart_products: {
type: [ProductSchema],
validate: [
{
validator: NotEmptyArrayValidator,
message: 'add_to_cart_products is required',
},
],
},
add_to_cart_discount: {
type: Number,
default: 0,
min: 0,
},
add_to_tax: {
type: Number,
default: 8,
},
};
谁能告诉我该怎么做?