MongoDB的命名约定是什么? [英] What are naming conventions for MongoDB?
问题描述
MongoDB实体是否有一组首选的命名约定,例如数据库,集合,字段名称?
Is there a set of preferred naming conventions for MongoDB entitites such as databases, collections, field names?
我一直在考虑以下方面:
I was thinking along these lines:
- 数据库:由目的(单数单词)组成,并以"db"结尾–所有小写:imagedb,resumedb,memberdb等.
- 收藏:小写复数:图片,简历,
- 文档字段:lowerCamelCase,例如memberFirstName,fileName等
推荐答案
-
保持简短:优化小型存储对象, SERVER-863 .愚蠢但真实.
我猜适用于关系数据库的规则几乎相同.在几十年后,仍未就RDBMS表应命名为单数还是复数达成共识.
I guess pretty much the same rules that apply to relation databases should apply here. And after so many decades there is still no agreement whether RDBMS tables should be named singular or plural...
MongoDB讲JavaScript,因此请使用camelCase的JS命名约定.
MongoDB speaks JavaScript, so utilize JS naming conventions of camelCase.
MongoDB官方文档提到您可以使用下划线,并且内置标识符也称为_id
(但这可能是为了表明_id
旨在是私有的,内部的,从不显示或编辑的).
MongoDB official documentation mentions you may use underscores, also built-in identifier is named _id
(but this may be be to indicate that _id
is intended to be private, internal, never displayed or edited.
这篇关于MongoDB的命名约定是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!