From 3343adb95257daae0be49daf6c768788292ef267 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 4 Aug 2022 10:59:56 -0400 Subject: [PATCH] feat: allows querying on rich text content --- src/mongoose/buildQuery.ts | 4 ++++ test/fields/int.spec.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/mongoose/buildQuery.ts b/src/mongoose/buildQuery.ts index 1396bf69c4..3f8d0f766e 100644 --- a/src/mongoose/buildQuery.ts +++ b/src/mongoose/buildQuery.ts @@ -199,6 +199,10 @@ class ParamParser { ]; return; } + + if (priorSchemaType.instance === 'Mixed') { + lastIncompletePath.path = currentPath; + } } if (operator === 'near') { diff --git a/test/fields/int.spec.ts b/test/fields/int.spec.ts index 646c95d891..48ac06067e 100644 --- a/test/fields/int.spec.ts +++ b/test/fields/int.spec.ts @@ -232,4 +232,30 @@ describe('Fields', () => { expect(blockFields.docs[0].blocks[2].subBlocks[1].text).toEqual(blocksFieldSeedData[2].subBlocks[1].text); }); }); + + describe('richText', () => { + it('should allow querying on rich text content', async () => { + const emptyRichTextQuery = await payload.find({ + collection: 'rich-text-fields', + where: { + 'richText.children.text': { + like: 'doesnt exist', + }, + }, + }); + + expect(emptyRichTextQuery.docs).toHaveLength(0); + + const workingRichTextQuery = await payload.find({ + collection: 'rich-text-fields', + where: { + 'richText.children.text': { + like: 'hello', + }, + }, + }); + + expect(workingRichTextQuery.docs).toHaveLength(1); + }); + }); });