型号名称(Mongoose)的大写?
Capitalization of the model name (Mongoose)?
为什么模特的名字要大写。
正如在他们的文档中一样,他们将其大写。
var schema = new mongoose.Schema({ name: 'string', size: 'string' });
var Tank = mongoose.model('Tank', schema);
为什么Tank
在这里大写?有什么具体原因吗?
抱歉,如果这不是一个好问题。任何帮助将不胜感激:)
这只是一种编码约定。 Tank
模型被视为可实例化 class:
var small = new Tank({ size: 'small' });
根据 typical coding conventions,class 名称应为 UpperCamelCase
,首字母大写,实例变量应为 lowerCamelCase
(方法也应如此)。
var schema = new mongoose.Schema({ name: 'string', size: 'string' });
var Tank = mongoose.model('Tank', schema);
The first argument is the singular name of the collection your model
is for. ** Mongoose automatically looks for the plural, lowercased
version of your model name. ** Thus, for the example above, the model
Tank is for the tanks collection in the database.
为什么模特的名字要大写。 正如在他们的文档中一样,他们将其大写。
var schema = new mongoose.Schema({ name: 'string', size: 'string' });
var Tank = mongoose.model('Tank', schema);
为什么Tank
在这里大写?有什么具体原因吗?
抱歉,如果这不是一个好问题。任何帮助将不胜感激:)
这只是一种编码约定。 Tank
模型被视为可实例化 class:
var small = new Tank({ size: 'small' });
根据 typical coding conventions,class 名称应为 UpperCamelCase
,首字母大写,实例变量应为 lowerCamelCase
(方法也应如此)。
var schema = new mongoose.Schema({ name: 'string', size: 'string' }); var Tank = mongoose.model('Tank', schema);
The first argument is the singular name of the collection your model is for. ** Mongoose automatically looks for the plural, lowercased version of your model name. ** Thus, for the example above, the model Tank is for the tanks collection in the database.