Identifiers for mongoose models and schemas should always be appropriately suffixed with 'Fields', 'Doc', or 'Model', and must share the same prefix.
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);