Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Goose Model Proto Method: Discrepancy Between Type && Func Definition #11137

Closed
WormJim opened this issue Dec 23, 2021 · 0 comments
Closed

Goose Model Proto Method: Discrepancy Between Type && Func Definition #11137

WormJim opened this issue Dec 23, 2021 · 0 comments
Assignees
Labels
typescript Types or Types-test related issue / Pull Request
Milestone

Comments

@WormJim
Copy link

WormJim commented Dec 23, 2021

Report a [bug]

  • Node: 14.16.1
  • Mongoose: 6.1.1
  • Mongo dB: 4.1.2

The Mongoose#model definition Type differs from the Mongoose#model method

  • SkipInit Prop does not exist in Mongoose v 6.1.1
  • SkipInit was reported in issue here: Remove skipInit parameter for model() #4625
  • SkipInit was removed here: 1e18e5
  • SkiptInit was merged here: 6.0 #10596
  • The Type definition causes errors if a Boolean is passed where an options Object is required
  • There isn't a type definition for the options object

Mongoose#model definition Type

SkipInit is found on the Mongoose#model

mongoose/index.d.ts

Lines 123 to 129 in 17fcd47

export function model<T>(name: string, schema?: Schema<T, any, any> | Schema<T & Document, any, any>, collection?: string, skipInit?: boolean): Model<T>;
export function model<T, U, TQueryHelpers = {}>(
name: string,
schema?: Schema<T, U, TQueryHelpers>,
collection?: string,
skipInit?: boolean
): U;

Yet doesn't exisit on the Mongoose#model definition

mongoose/lib/index.js

Lines 454 to 461 in dbb7ed6

* @param {String|Function} name model name or class extending Model
* @param {Schema} [schema] the schema to use.
* @param {String} [collection] name (optional, inferred from model name)
* @return {Model} The model associated with `name`. Mongoose will create the model if it doesn't already exist.
* @api public
*/
Mongoose.prototype.model = function(name, schema, collection, options) {


I also found the same issue below. Though I haven't inspected the function it's self.

Connection#model definition Type

SkipInit is also found on the Connection#model Type

mongoose/index.d.ts

Lines 373 to 380 in 3aeb86a

/** Defines or retrieves a model. */
model<T>(name: string, schema?: Schema<any>, collection?: string): Model<T>;
model<T, U, TQueryHelpers = {}>(
name: string,
schema?: Schema<T, U, TQueryHelpers>,
collection?: string,
skipInit?: boolean
): U;

Yet Doesn't exist on the Connection#model definition

mongoose/lib/connection.js

Lines 1056 to 1066 in 3aeb86a

* @param {String|Function} name the model name or class extending Model
* @param {Schema} [schema] a schema. necessary when defining a model
* @param {String} [collection] name of mongodb collection (optional) if not given it will be induced from model name
* @param {Object} [options]
* @param {Boolean} [options.overwriteModels=false] If true, overwrite existing models with the same name to avoid `OverwriteModelError`
* @see Mongoose#model #index_Mongoose-model
* @return {Model} The compiled model
* @api public
*/
Connection.prototype.model = function(name, schema, collection, options) {

@vkarpov15 vkarpov15 added this to the 6.1.7 milestone Dec 30, 2021
@vkarpov15 vkarpov15 added the typescript Types or Types-test related issue / Pull Request label Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

No branches or pull requests

2 participants