diff --git a/src/mongoose/buildSchema.ts b/src/mongoose/buildSchema.ts index d89c95f51..74c2a33fb 100644 --- a/src/mongoose/buildSchema.ts +++ b/src/mongoose/buildSchema.ts @@ -335,6 +335,7 @@ const fieldToSchemaMap: Record = { options: { _id: false, id: false, + minimize: false, }, disableUnique: buildSchemaOptions.disableUnique, draftsEnabled: buildSchemaOptions.draftsEnabled, @@ -364,7 +365,11 @@ const fieldToSchemaMap: Record = { config, field.fields, { - options: { _id: false, id: false }, + options: { + _id: false, + id: false, + minimize: false, + }, allowIDField: true, disableUnique: buildSchemaOptions.disableUnique, draftsEnabled: buildSchemaOptions.draftsEnabled, @@ -388,6 +393,7 @@ const fieldToSchemaMap: Record = { options: { _id: false, id: false, + minimize: false, }, disableUnique: buildSchemaOptions.disableUnique, draftsEnabled: buildSchemaOptions.draftsEnabled, diff --git a/test/fields/collections/JSON/index.tsx b/test/fields/collections/JSON/index.tsx index 2f33199ea..451c26453 100644 --- a/test/fields/collections/JSON/index.tsx +++ b/test/fields/collections/JSON/index.tsx @@ -10,6 +10,9 @@ type JSONField = { const JSON: CollectionConfig = { slug: 'json-fields', + versions: { + maxPerDoc: 1, + }, fields: [ { name: 'json', diff --git a/test/fields/int.spec.ts b/test/fields/int.spec.ts index 98590b7f6..9f3ea9fd8 100644 --- a/test/fields/int.spec.ts +++ b/test/fields/int.spec.ts @@ -529,7 +529,7 @@ describe('Fields', () => { }); it('should save empty json objects', async () => { - const createdJSON = await payload.create({ + const jsonFieldsDoc = await payload.create({ collection: 'json-fields', data: { json: { @@ -538,30 +538,11 @@ describe('Fields', () => { }, }); - expect(createdJSON.json.state).toEqual({}); - }); + expect(jsonFieldsDoc.json.state).toEqual({}); - it('should save empty json objects via REST', async () => { - const jsonClient = new RESTClient(config, { serverURL, defaultSlug: 'json-fields' }); - await jsonClient.login(); - - const { doc: ogDoc } = await jsonClient.create({ - auth: true, - data: { - json: { - empty: {}, - state: { - foo: 'bar', - }, - }, - }, - }); - - expect(ogDoc.json.empty).toEqual({}); - - const { doc } = await jsonClient.update({ - auth: true, - id: ogDoc.id, + const updatedJsonFieldsDoc = await payload.update({ + collection: 'json-fields', + id: jsonFieldsDoc.id, data: { json: { state: {}, @@ -569,7 +550,7 @@ describe('Fields', () => { }, }); - expect(doc.json.state).toEqual({}); + expect(updatedJsonFieldsDoc.json.state).toEqual({}); }); }); diff --git a/test/globals/int.spec.ts b/test/globals/int.spec.ts index 46a8e9978..7bd009e20 100644 --- a/test/globals/int.spec.ts +++ b/test/globals/int.spec.ts @@ -57,19 +57,6 @@ describe('globals', () => { expect(doc.array).toMatchObject(array); expect(doc.id).toBeDefined(); }); - - it('should save empty json objects', async () => { - const { doc } = await client.updateGlobal({ - slug, - data: { - json: { - state: {}, - }, - }, - }); - - expect(doc.json.state).toEqual({}); - }); }); describe('local', () => {