Skip to content
This repository was archived by the owner on Mar 15, 2023. It is now read-only.

Latest commit

 

History

History
43 lines (31 loc) · 1.06 KB

File metadata and controls

43 lines (31 loc) · 1.06 KB

Follow naming conventions for Mongoose models and schemas. (mongoose-naming-convention)

Identifiers for mongoose models and schemas should always be appropriately suffixed with 'Fields', 'Doc', or 'Model', and must share the same prefix.

Rule Details

For a collection X, we use the following naming conventions:

XFields = typeof schema;
XDoc = XFields & mongoose.Document;
XModel = model<XDoc>(schema, options);

Examples of incorrect code for this rule:

type CollectionDoc = Collection & mongoose.Document;
type CollectionDocument = CollectionFields & mongoose.Document;
const Collection = model<CollectionDoc>("Collection", CollectionSchema);
type CollectionDoc = ColectionFields & mongoose.Document;
const ColectionModel = model<CollectionDoc>("Collection", CollectionSchema);

Examples of correct code for this rule:

type CollectionFields = typeof CollectionSchema;
type CollectionDoc = CollectionFields & mongoose.Document;
const CollectionModel = model<CollectionDoc>(schema, options);