MongoDB的命名约定是什么? [英] What are naming conventions for MongoDB?

查看:72
本文介绍了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等

推荐答案

  1. 保持简短:优化小型存储对象 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆