修改表中数据时,表中字段类型是Boolean时,字符串和数字都会直接转换为true,而字符串格式类型的字段接收任何传入修改的数据类型。怎么能做到完整的,严格的数据验证
The questioner should be asking about document validation; View the official document directly: https://docs.mongodb.com/manual/core/document-validation/
db.createCollection( "contacts", { validator: { $or: [ { phone: { $type: "string" } }, { email: { $regex: /@mongodb\.com$/ } }, { status: { $in: [ "Unknown", "Incomplete" ] } } ] } } ) 具体怎么用还要结合你的需求和mongo的文档来搞
The questioner should be asking about document validation;
View the official document directly: https://docs.mongodb.com/manual/core/document-validation/