MongoDB:强制字段的数据类型? [英] MongoDB: Force datatype of fields?
本文介绍了MongoDB:强制字段的数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是MongoDB:类 java.lang.Double 不能转换为类 java.lang.Long
问题可能是任何指定的字段实际上都存储为 Double 而不是 Long.
The problem probably is that any of the indicated fields is actually stored as Double instead of Long.
有没有办法可以强制为 MongoDB 中的某些字段设置数据类型?
Is there a way that I can force a datatype for some fields in MongoDB?
如果数据类型不匹配,我希望文档插入失败.
I want the insert of a document to fail, if the datatype does not match.
推荐答案
使用架构验证,如 https://docs.mongodb.com/manual/core/schema-validation/
这篇关于MongoDB:强制字段的数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文