我打算在Mongo Shell上运行以下命令,一旦我完善了它所需要的集合。然而,我无法弄清楚如何处理我所需属性列表中的最后一项,因为它是唯一一个数组。具体来说,它是一个字符串数组。它是最后一项,即imageIDs
属性。我放置了enum
,但我认为那不对。我该如何要求其类型为字符串数组?
db.runCommand( {
collMod: "CustomerOrders",
validator: { $jsonSchema: {
bsonType: "object",
required: [ "dateTime", "restaurantName", "restaurantCity", "restaurantCountry", "contactName", "contactPhone", "contactEmail", "menuSize", "pricePaid", "currentLanguage", "targetLanguage", "imageIDs" ],
properties: {
dateTime: {
bsonType: "string",
description: "must be a string and is required"
},
restaurantName: {
bsonType: "string",
description: "must be a string and is required"
},
restaurantCity: {
bsonType: "string",
description: "must be a string and is required"
},
restaurantCountry: {
bsonType: "string",
description: "must be a string and is required"
},
contactName: {
bsonType: "string",
description: "must be a string and is required"
},
contactPhone: {
bsonType: "string",
description: "must be a string and is required"
},
contactEmail: {
bsonType: "string",
description: "must be a string and is required"
},
menuSize: {
bsonType: "string",
description: "must be a string and is required"
},
pricePaid: {
bsonType: "double",
description: "must be a string and is required"
},
currentLanguage: {
bsonType: "string",
description: "must be a string and is required"
},
targetLanguage: {
bsonType: "string",
description: "must be a string and is required"
},
imageIDs: {
bsonType: "enum",
description: "can only be one of the enum values and is required"
}
}
} },
validationLevel: "strict"
} )