From a2158341d855bf1aa8b1d80e282f67d864596b0e Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 14 Aug 2016 23:53:38 -0400 Subject: [PATCH] moved properties of Model and model into a separate interface --- mongoose/mongoose-tests.ts | 4 ++++ mongoose/mongoose.d.ts | 32 ++++++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/mongoose/mongoose-tests.ts b/mongoose/mongoose-tests.ts index 2b00e665cd..ddec97e9d1 100644 --- a/mongoose/mongoose-tests.ts +++ b/mongoose/mongoose-tests.ts @@ -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); diff --git a/mongoose/mongoose.d.ts b/mongoose/mongoose.d.ts index 3b6590feda..a6a2fc409c 100644 --- a/mongoose/mongoose.d.ts +++ b/mongoose/mongoose.d.ts @@ -2040,7 +2040,7 @@ declare module "mongoose" { * section model.js * http://mongoosejs.com/docs/api.html#model-js */ - interface Model extends NodeJS.EventEmitter { + interface Model 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; } - 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; + } + 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; }