{"record":{"id":"74270e82a38abfb8","repo":"Automattic/mongoose","slug":"mongoose-74270e","errorCode":"MONGOOSE","errorMessage":"mongoose: the method name \"${method}\" is used by mongoose internally, overwriting it may cause bugs. If you're sure you know what you're doing, you can suppress this error by using `schema.method('${method}', fn, { suppressWarning: true })`.","messagePattern":"mongoose: the method name \"(.+?)\" is used by mongoose internally, overwriting it may cause bugs\\. If you're sure you know what you're doing, you can suppress this error by using `schema\\.method\\('(.+?)', fn, (.+?)\\)`\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/helpers/model/applyMethods.js","lineNumber":47,"sourceCode":"  for (const method of Object.keys(schema.methods)) {\n    const fn = schema.methods[method];\n    if (Object.hasOwn(schema.tree, method)) {\n      throw new Error('You have a method and a property in your schema both ' +\n        'named \"' + method + '\"');\n    }\n\n    // Avoid making custom methods if user sets a method to itself, e.g.\n    // `schema.method(save, Document.prototype.save)`. Can happen when\n    // calling `loadClass()` with a class that `extends Document`. See gh-12254\n    if (typeof fn === 'function' &&\n        Model.prototype[method] === fn) {\n      delete schema.methods[method];\n      continue;\n    }\n\n    if (schema.reserved[method] &&\n        !get(schema, `methodOptions.${method}.suppressWarning`, false)) {\n      utils.warn(`mongoose: the method name \"${method}\" is used by mongoose ` +\n        'internally, overwriting it may cause bugs. If you\\'re sure you know ' +\n        'what you\\'re doing, you can suppress this error by using ' +\n        `\\`schema.method('${method}', fn, { suppressWarning: true })\\`.`);\n    }\n    if (typeof fn === 'function') {\n      model.prototype[method] = fn;\n    } else {\n      apply(method, schema);\n    }\n  }\n\n  // Recursively call `applyMethods()` on child schemas\n  model.$appliedMethods = true;\n  for (const key of Object.keys(schema.paths)) {\n    const type = schema.paths[key];\n    if (type.$isSingleNested && !type.Constructor.$appliedMethods) {\n      applyMethods(type.Constructor, type.schema);\n    }","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/Automattic/mongoose/blob/49cdab01366679723b487ecb754b38570f783289/lib/helpers/model/applyMethods.js#L29-L65","documentation":"Error \"mongoose: the method name \"${method}\" is used by mongoose internally, overwriting it may cause bugs. If you're sure you know what you're doing, you can suppress this error by using `schema.method('${method}', fn, { suppressWarning: true })`.\" thrown in Automattic/mongoose.","triggerScenarios":"Thrown at lib/helpers/model/applyMethods.js:47 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49cdab01366679723b487ecb754b38570f783289","analyzedAt":"2026-08-21T22:54:00.882Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}