{"record":{"id":"ffe946b97001f0be","repo":"Automattic/mongoose","slug":"mongoose-ffe946","errorCode":"MONGOOSE","errorMessage":"mongoose: calling `save()` on a subdoc does **not** save the document to MongoDB, it only runs save middleware. Use `subdoc.save({ suppressWarning: true })` to hide this warning if you're sure this behavior is right for your app.","messagePattern":"mongoose: calling `save\\(\\)` on a subdoc does \\*\\*not\\*\\* save the document to MongoDB, it only runs save middleware\\. Use `subdoc\\.save\\((.+?)\\)` to hide this warning if you're sure this behavior is right for your app\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/types/subdocument.js","lineNumber":76,"sourceCode":" *\n * #### Note:\n *\n * _This is a no-op. Does not actually save the doc to the db._\n *\n * @param {object} [options]\n * @param {boolean} [options.suppressWarning=false] If `true`, suppress the warning about calling `save()` on a subdoc.\n * @param {boolean|object} [options.middleware=true] set to `false` to skip all user-defined middleware\n * @param {boolean} [options.middleware.pre=true] set to `false` to skip only pre hooks\n * @param {boolean} [options.middleware.post=true] set to `false` to skip only post hooks\n * @return {Promise} resolved Promise\n * @api private\n */\n\nSubdocument.prototype.save = async function save(options) {\n  options = options || {};\n\n  if (!options.suppressWarning) {\n    utils.warn('mongoose: calling `save()` on a subdoc does **not** save ' +\n      'the document to MongoDB, it only runs save middleware. ' +\n      'Use `subdoc.save({ suppressWarning: true })` to hide this warning ' +\n      'if you\\'re sure this behavior is right for your app.');\n  }\n\n  return await this.$__save(options);\n};\n\n/**\n * Given a path relative to this document, return the path relative\n * to the top-level document.\n * @param {string} path\n * @method $__fullPath\n * @memberOf Subdocument\n * @instance\n * @returns {string}\n * @api private\n */","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/Automattic/mongoose/blob/49cdab01366679723b487ecb754b38570f783289/lib/types/subdocument.js#L58-L94","documentation":"Error \"mongoose: calling `save()` on a subdoc does **not** save the document to MongoDB, it only runs save middleware. Use `subdoc.save({ suppressWarning: true })` to hide this warning if you're sure this behavior is right for your app.\" thrown in Automattic/mongoose.","triggerScenarios":"Thrown at lib/types/subdocument.js:76 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"}