diff --git a/docs/versions/overview.mdx b/docs/versions/overview.mdx index 16d26070f3..af67c77455 100644 --- a/docs/versions/overview.mdx +++ b/docs/versions/overview.mdx @@ -55,7 +55,7 @@ Configuring Versions is done by adding the `versions` key to your Collection con | Option | Description | | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `maxPerDoc` | Use this setting to control how many versions to keep on a document by document basis. Must be an integer. | +| `maxPerDoc` | Use this setting to control how many versions to keep on a document by document basis. Must be an integer. Defaults to 100, use 0 to save all versions. | | `drafts ` | Enable [Drafts](/docs/versions/drafts) mode for this collection. To enable, set to `true` or pass an object with `draft` [options](/docs/versions/drafts#options). | ### Global config diff --git a/src/versions/saveVersion.ts b/src/versions/saveVersion.ts index a02cb3213b..b9b8eb1fd9 100644 --- a/src/versions/saveVersion.ts +++ b/src/versions/saveVersion.ts @@ -94,12 +94,12 @@ export const saveVersion = async ({ payload.logger.error(err); } - let max: number; + let max = 100; if (collection && typeof collection.versions.maxPerDoc === 'number') max = collection.versions.maxPerDoc; if (global && typeof global.versions.max === 'number') max = global.versions.max; - if (collection && collection.versions.maxPerDoc) { + if (max > 0) { enforceMaxVersions({ id, payload,