> ## Documentation Index
> Fetch the complete documentation index at: https://loadwise.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# mongoose-hydrate-for-to-object

> A Mongoose query hydrates full Documents only to convert them immediately via .toObject() or .toJSON().

## What it flags

A Mongoose `find`, `findOne` or `findById` result is only null-checked and converted with `.toObject()` or `.toJSON()`.

## How to review or fix

Append `.lean()` to skip hydration. Skipped when a schema customizes `toObject` or `toJSON`. A lean result also skips schema defaults, getters and virtuals, so a stored document that lacks a defaulted field comes back without it; check that callers do not rely on those before applying the change. For that reason the inline fix requires review, and `--yes` does not apply it.

## Configuration

Set the rule to `"off"` in `loadwise.config.json` to drop its findings:

```json theme={null}
{
  "rules": { "mongoose-hydrate-for-to-object": "off" }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.