moved properties of Model and model into a separate interface

This commit is contained in:
Simon
2016-08-21 14:11:33 -04:00
parent 6d2d24d72a
commit a2158341d8
2 changed files with 30 additions and 6 deletions
+4
View File
@@ -1249,6 +1249,10 @@ mongoModel.discriminators;
mongoModel.modelName.toLowerCase();
MongoModel = mongoModel.base.model('new', mongoModel.schema);
/* inherited properties */
MongoModel.modelName;
mongoModel.modelName;
MongoModel.collection;
mongoModel.collection;
mongoModel._id;
mongoModel.execPopulate();
mongoModel.on('data', cb);
+26 -6
View File
@@ -2040,7 +2040,7 @@ declare module "mongoose" {
* section model.js
* http://mongoosejs.com/docs/api.html#model-js
*/
interface Model<T extends Document> extends NodeJS.EventEmitter {
interface Model<T extends Document> extends NodeJS.EventEmitter, ModelProperties {
/**
* Model constructor
* Provides the interface to MongoDB collections as well as creates document instances.
@@ -2059,14 +2059,26 @@ declare module "mongoose" {
*/
new(doc?: Object): T;
/** The name of the model. */
modelName: string;
/** Base Mongoose instance the model uses. */
base: typeof mongoose;
/** If this is a discriminator model, `baseModelName` is the name of the base model. */
baseModelName: string;
/** Collection the model uses. */
collection: Collection;
/** If this is a discriminator model, `baseModelName` is the name of the base model. */
baseModelName: string;
/** Connection the model uses. */
db: Connection;
/** Registered discriminators for this model. */
discriminators: any;
/** The name of the model. */
modelName: string;
/** Schema the model uses. */
schema: Schema;
/**
* Finds a single document by its _id field. findById(id) is almost*
@@ -2304,7 +2316,7 @@ declare module "mongoose" {
where(path: string, val?: Object): Query<any>;
}
interface Document extends MongooseDocument, NodeJS.EventEmitter {
interface Document extends MongooseDocument, NodeJS.EventEmitter, ModelProperties {
/** Signal that we desire an increment of this documents version. */
increment(): this;
@@ -2328,22 +2340,30 @@ declare module "mongoose" {
* @param fn optional callback
*/
save(fn?: (err: any, product: this, numAffected: number) => void): _MongoosePromise<this>;
}
interface ModelProperties {
/** Base Mongoose instance the model uses. */
base: typeof mongoose;
/**
* If this is a discriminator model, baseModelName is the
* name of the base model.
*/
baseModelName: String;
/** Collection the model uses. */
collection: Collection;
/** Connection the model uses. */
db: Connection;
/** Registered discriminators for this model. */
discriminators: any;
/** The name of the model */
modelName: string;
/** Schema the model uses. */
schema: Schema;
}