From ab7b14d81e8db1606d7ded978c4dd6c20281b042 Mon Sep 17 00:00:00 2001 From: Jarrod Flesch Date: Tue, 31 Jan 2023 11:29:52 -0500 Subject: [PATCH] chore: defaults maxVersions to 100 --- docs/versions/overview.mdx | 2 +- src/versions/saveVersion.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/versions/overview.mdx b/docs/versions/overview.mdx index 13872c0ec..cc5d8dfb4 100644 --- a/docs/versions/overview.mdx +++ b/docs/versions/overview.mdx @@ -52,7 +52,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. | | `retainDeleted` | Boolean to determine if, when a document is deleted, you'd like to retain versions of that document, or go through and automatically delete all versions that are associated with the deleted document. | | `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). | diff --git a/src/versions/saveVersion.ts b/src/versions/saveVersion.ts index a02cb3213..b9b8eb1fd 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,