Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongodb schema design naming convention

So I have something called

exports.create = function(projectJSON){

 var project = new ProjectModel({
   id : projectJSON.id,
   projectName : projectJSON.projectName ,
   authorName : projectJSON.authorName,
   firstPostDate : projectJSON.firstPostDate

 })
}

Is the above naming convention for a multi-word element firstPostDate (camel case) correct, or should they be spaced with _ in all lowercase?

I see that other blogs prefer it to be in small caps..

EDIT:

Also I read that elements should be singular instead of plural ie:

`comment` instead of `comments` for a blog schema design
like image 543
bouncingHippo Avatar asked Nov 06 '12 19:11

bouncingHippo


1 Answers

I use Google's JSON Style Guide myself and they suggest using camelCase i.e. firstPostDate. Below is the section excerpt

Property Name Format

Property names must conform to the following guidelines:

  • Property names should be meaningful names with defined semantics.
  • Property names must be camel-cased, ascii strings.
  • The first character must be a letter, an underscore (_) or a dollar sign ($).
  • Subsequent characters can be a letter, a digit, an underscore, or a dollar sign.
  • Reserved JavaScript keywords should be avoided (A list of reserved JavaScript keywords can be found below).

These guidelines mirror the guidelines for naming JavaScript identifiers. This allows JavaScript clients to access properties using dot notation. (for example, result.thisIsAnInstanceVariable). Here's an example of an object with one property:

{
  "thisPropertyIsAnIdentifier": "identifier value"
}
like image 187
Aravind Yarram Avatar answered Oct 04 '22 10:10

Aravind Yarram