{"record":{"id":"3e6ada5bc6b4a61b","repo":"Automattic/mongoose","slug":"the-skipid-parameter-has-been-removed-use-skipi","errorCode":null,"errorMessage":"The skipId parameter has been removed. Use { skipId: true } in the options parameter instead.","messagePattern":"The skipId parameter has been removed\\. Use (.+?) in the options parameter instead\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/document.js","lineNumber":94,"sourceCode":"\n/**\n * The core Mongoose document constructor. You should not call this directly,\n * the Mongoose [Model constructor](./api/model.html#Model) calls this for you.\n *\n * @param {object} obj the values to set\n * @param {object} [fields] optional object containing the fields which were selected in the query returning this document and any populated paths data\n * @param {object} [options] various configuration options for the document\n * @param {boolean} [options.defaults=true] if `false`, skip applying default values to this document.\n * @param {boolean} [options.skipId=false] By default, Mongoose document if one is not provided and the document's schema does not override Mongoose's default `_id`. Set `skipId` to `true` to skip this generation step.\n * @inherits NodeJS EventEmitter https://nodejs.org/api/events.html#class-eventemitter\n * @event `init`: Emitted on a document after it has been retrieved from the db and fully hydrated by Mongoose.\n * @event `save`: Emitted when the document is successfully saved\n * @api private\n */\n\nfunction Document(obj, fields, options) {\n  if (typeof options === 'boolean') {\n    throw new Error('The skipId parameter has been removed. Use { skipId: true } in the options parameter instead.');\n  }\n  options = options == null ? {} : Object.assign({}, options);\n  let skipId = options.skipId;\n\n  this.$__ = new InternalCache();\n\n  // Support `browserDocument.js` syntax\n  if (this.$__schema == null) {\n    const _schema = utils.isObject(fields) && !fields.instanceOfSchema ?\n      new Schema(fields) :\n      fields;\n\n    this.$__setSchema(_schema);\n    fields = options;\n    skipId = options.skipId;\n  }\n\n  // Avoid setting `isNew` to `true`, because it is `true` by default","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/Automattic/mongoose/blob/49cdab01366679723b487ecb754b38570f783289/lib/document.js#L76-L112","documentation":"Older Mongoose accepted a boolean third parameter to the Document/Model constructor to skip automatic _id generation. That positional flag moved into an options object ({ skipId: true }); passing a boolean now throws so stale call sites fail loudly rather than being misread as options.","triggerScenarios":"new MyModel(obj, fields, true), new MyModel(obj, null, false), or new mongoose.Document(obj, schema, true) — any boolean as the third constructor argument.","commonSituations":"Codebases migrated from Mongoose 4/5/6; generic document factories that forwarded legacy positional arguments; old Stack Overflow snippets still using the boolean form.","solutions":["Move the flag into an options object: new MyModel(obj, fields, { skipId: true })","Drop the third argument entirely when default _id generation is desired"],"exampleFix":"// before\nconst doc = new MyModel(data, selectedFields, true);\n\n// after\nconst doc = new MyModel(data, selectedFields, { skipId: true });","handlingStrategy":"validation","validationCode":"function createDoc(Model, obj, fields, opts) {\n  if (typeof opts === 'boolean') opts = { skipId: opts }; // normalize legacy positional flag\n  return new Model(obj, fields, opts);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass booleans positionally to document constructors","Search for 'new ' + model names with a third boolean argument when upgrading from Mongoose <= 6","Keep constructor call sites behind a factory so signature changes are fixed in one place"],"tags":["document","constructor","skipid","mongoose-6","migration"],"backgroundTag":"api-signature-changed","analyzedSha":"49cdab01366679723b487ecb754b38570f783289","analyzedAt":"2026-08-21T22:54:00.882Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}