@payloadcms/db-mongodb 3.33.0-internal.d1efdd8 → 3.34.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"parseParams.d.ts","sourceRoot":"","sources":["../../src/queries/parseParams.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAY,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAQvE,wBAAsB,WAAW,CAAC,EAChC,cAAc,EACd,MAAM,EACN,UAAU,EACV,MAAM,EACN,iBAAiB,EACjB,OAAO,EACP,KAAK,GACN,EAAE;IACD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,iBAAiB,EAAE,OAAO,CAAA;IAC1B,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,KAAK,CAAA;CACb,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAyEnC"}
1
+ {"version":3,"file":"parseParams.d.ts","sourceRoot":"","sources":["../../src/queries/parseParams.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAY,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAQvE,wBAAsB,WAAW,CAAC,EAChC,cAAc,EACd,MAAM,EACN,UAAU,EACV,MAAM,EACN,iBAAiB,EACjB,OAAO,EACP,KAAK,GACN,EAAE;IACD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,iBAAiB,EAAE,OAAO,CAAA;IAC1B,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,KAAK,CAAA;CACb,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAqFnC"}
@@ -55,7 +55,20 @@ export async function parseParams({ collectionSlug, fields, globalSlug, locale,
55
55
  [searchParam.path]: searchParam.value
56
56
  });
57
57
  } else {
58
- result[searchParam.path] = searchParam.value;
58
+ if (result[searchParam.path]) {
59
+ if (!result.$and) {
60
+ result.$and = [];
61
+ }
62
+ result.$and.push({
63
+ [searchParam.path]: result[searchParam.path]
64
+ });
65
+ result.$and.push({
66
+ [searchParam.path]: searchParam.value
67
+ });
68
+ delete result[searchParam.path];
69
+ } else {
70
+ result[searchParam.path] = searchParam.value;
71
+ }
59
72
  }
60
73
  } else if (typeof searchParam?.value === 'object') {
61
74
  result = deepMergeWithCombinedArrays(result, searchParam.value ?? {}, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/queries/parseParams.ts"],"sourcesContent":["import type { FilterQuery } from 'mongoose'\nimport type { FlattenedField, Operator, Payload, Where } from 'payload'\n\nimport { deepMergeWithCombinedArrays } from 'payload'\nimport { validOperatorSet } from 'payload/shared'\n\nimport { buildAndOrConditions } from './buildAndOrConditions.js'\nimport { buildSearchParam } from './buildSearchParams.js'\n\nexport async function parseParams({\n collectionSlug,\n fields,\n globalSlug,\n locale,\n parentIsLocalized,\n payload,\n where,\n}: {\n collectionSlug?: string\n fields: FlattenedField[]\n globalSlug?: string\n locale?: string\n parentIsLocalized: boolean\n payload: Payload\n where: Where\n}): Promise<Record<string, unknown>> {\n let result = {} as FilterQuery<any>\n\n if (typeof where === 'object') {\n // We need to determine if the whereKey is an AND, OR, or a schema path\n for (const relationOrPath of Object.keys(where)) {\n const condition = where[relationOrPath]\n let conditionOperator: '$and' | '$or' | null = null\n if (relationOrPath.toLowerCase() === 'and') {\n conditionOperator = '$and'\n } else if (relationOrPath.toLowerCase() === 'or') {\n conditionOperator = '$or'\n }\n if (Array.isArray(condition)) {\n const builtConditions = await buildAndOrConditions({\n collectionSlug,\n fields,\n globalSlug,\n locale,\n parentIsLocalized,\n payload,\n where: condition,\n })\n if (builtConditions.length > 0 && conditionOperator !== null) {\n result[conditionOperator] = builtConditions\n }\n } else {\n // It's a path - and there can be multiple comparisons on a single path.\n // For example - title like 'test' and title not equal to 'tester'\n // So we need to loop on keys again here to handle each operator independently\n const pathOperators = where[relationOrPath]\n if (typeof pathOperators === 'object') {\n const validOperators = Object.keys(pathOperators).filter((operator) =>\n validOperatorSet.has(operator as Operator),\n )\n\n for (const operator of validOperators) {\n const searchParam = await buildSearchParam({\n collectionSlug,\n fields,\n globalSlug,\n incomingPath: relationOrPath,\n locale,\n operator,\n parentIsLocalized,\n payload,\n val: (pathOperators as Record<string, Where>)[operator],\n })\n\n if (searchParam?.value && searchParam?.path) {\n if (validOperators.length > 1) {\n if (!result.$and) {\n result.$and = []\n }\n result.$and.push({\n [searchParam.path]: searchParam.value,\n })\n } else {\n result[searchParam.path] = searchParam.value\n }\n } else if (typeof searchParam?.value === 'object') {\n result = deepMergeWithCombinedArrays(result, searchParam.value ?? {}, {\n // dont clone Types.ObjectIDs\n clone: false,\n })\n }\n }\n }\n }\n }\n }\n\n return result\n}\n"],"names":["deepMergeWithCombinedArrays","validOperatorSet","buildAndOrConditions","buildSearchParam","parseParams","collectionSlug","fields","globalSlug","locale","parentIsLocalized","payload","where","result","relationOrPath","Object","keys","condition","conditionOperator","toLowerCase","Array","isArray","builtConditions","length","pathOperators","validOperators","filter","operator","has","searchParam","incomingPath","val","value","path","$and","push","clone"],"mappings":"AAGA,SAASA,2BAA2B,QAAQ,UAAS;AACrD,SAASC,gBAAgB,QAAQ,iBAAgB;AAEjD,SAASC,oBAAoB,QAAQ,4BAA2B;AAChE,SAASC,gBAAgB,QAAQ,yBAAwB;AAEzD,OAAO,eAAeC,YAAY,EAChCC,cAAc,EACdC,MAAM,EACNC,UAAU,EACVC,MAAM,EACNC,iBAAiB,EACjBC,OAAO,EACPC,KAAK,EASN;IACC,IAAIC,SAAS,C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C;4BACF,OAAO;gCACLnB,MAAM,CAACgB,YAAYI,IAAI,CAAC,GAAGJ,YAAYG,KAAK;4BAC9C;wBACF,OAAO,IAAI,OAAOH,aAAaG,UAAU,UAAU;4BACjDnB,SAASZ,4BAA4BY,QAAQgB,YAAYG,KAAK,IAAI,CAAC,GAAG;gCACpE,6BAA6B;gCAC7BI,OAAO;4BACT;wBACF;oBACF;gBACF;YACF;QACF;IACF;IAEA,OAAOvB;AACT"}
1
+ {"version":3,"sources":["../../src/queries/parseParams.ts"],"sourcesContent":["import type { FilterQuery } from 'mongoose'\nimport type { FlattenedField, Operator, Payload, Where } from 'payload'\n\nimport { deepMergeWithCombinedArrays } from 'payload'\nimport { validOperatorSet } from 'payload/shared'\n\nimport { buildAndOrConditions } from './buildAndOrConditions.js'\nimport { buildSearchParam } from './buildSearchParams.js'\n\nexport async function parseParams({\n collectionSlug,\n fields,\n globalSlug,\n locale,\n parentIsLocalized,\n payload,\n where,\n}: {\n collectionSlug?: string\n fields: FlattenedField[]\n globalSlug?: string\n locale?: string\n parentIsLocalized: boolean\n payload: Payload\n where: Where\n}): Promise<Record<string, unknown>> {\n let result = {} as FilterQuery<any>\n\n if (typeof where === 'object') {\n // We need to determine if the whereKey is an AND, OR, or a schema path\n for (const relationOrPath of Object.keys(where)) {\n const condition = where[relationOrPath]\n let conditionOperator: '$and' | '$or' | null = null\n if (relationOrPath.toLowerCase() === 'and') {\n conditionOperator = '$and'\n } else if (relationOrPath.toLowerCase() === 'or') {\n conditionOperator = '$or'\n }\n if (Array.isArray(condition)) {\n const builtConditions = await buildAndOrConditions({\n collectionSlug,\n fields,\n globalSlug,\n locale,\n parentIsLocalized,\n payload,\n where: condition,\n })\n if (builtConditions.length > 0 && conditionOperator !== null) {\n result[conditionOperator] = builtConditions\n }\n } else {\n // It's a path - and there can be multiple comparisons on a single path.\n // For example - title like 'test' and title not equal to 'tester'\n // So we need to loop on keys again here to handle each operator independently\n const pathOperators = where[relationOrPath]\n if (typeof pathOperators === 'object') {\n const validOperators = Object.keys(pathOperators).filter((operator) =>\n validOperatorSet.has(operator as Operator),\n )\n\n for (const operator of validOperators) {\n const searchParam = await buildSearchParam({\n collectionSlug,\n fields,\n globalSlug,\n incomingPath: relationOrPath,\n locale,\n operator,\n parentIsLocalized,\n payload,\n val: (pathOperators as Record<string, Where>)[operator],\n })\n\n if (searchParam?.value && searchParam?.path) {\n if (validOperators.length > 1) {\n if (!result.$and) {\n result.$and = []\n }\n result.$and.push({\n [searchParam.path]: searchParam.value,\n })\n } else {\n if (result[searchParam.path]) {\n if (!result.$and) {\n result.$and = []\n }\n\n result.$and.push({ [searchParam.path]: result[searchParam.path] })\n result.$and.push({\n [searchParam.path]: searchParam.value,\n })\n delete result[searchParam.path]\n } else {\n result[searchParam.path] = searchParam.value\n }\n }\n } else if (typeof searchParam?.value === 'object') {\n result = deepMergeWithCombinedArrays(result, searchParam.value ?? {}, {\n // dont clone Types.ObjectIDs\n clone: false,\n })\n }\n }\n }\n }\n }\n }\n\n return result\n}\n"],"names":["deepMergeWithCombinedArrays","validOperatorSet","buildAndOrConditions","buildSearchParam","parseParams","collectionSlug","fields","globalSlug","locale","parentIsLocalized","payload","where","result","relationOrPath","Object","keys","condition","conditionOperator","toLowerCase","Array","isArray","builtConditions","length","pathOperators","validOperators","filter","operator","has","searchParam","incomingPath","val","value","path","$and","push","clone"],"mappings":"AAGA,SAASA,2BAA2B,QAAQ,UAAS;AACrD,SAASC,gBAAgB,QAAQ,iBAAgB;AAEjD,SAASC,oBAAoB,QAAQ,4BAA2B;AAChE,SAASC,gBAAgB,QAAQ,yBAAwB;AAEzD,OAAO,eAAeC,YAAY,EAChCC,cAAc,EACdC,MAAM,EACNC,UAAU,EACVC,MAAM,EACNC,iBAAiB,EACjBC,OAAO,EACPC,KAAK,EASN;IACC,IAAIC,SAAS,CAAC;IAEd,IAAI,OAAOD,UAAU,UAAU;QAC7B,uEAAuE;QACvE,KAAK,MAAME,kBAAkBC,OAAOC,IAAI,CA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,IAAI,EAAE;wCAChBrB,OAAOqB,IAAI,GAAG,EAAE;oCAClB;oCAEArB,OAAOqB,IAAI,CAACC,IAAI,CAAC;wCAAE,CAACN,YAAYI,IAAI,CAAC,EAAEpB,MAAM,CAACgB,YAAYI,IAAI,CAAC;oCAAC;oCAChEpB,OAAOqB,IAAI,CAACC,IAAI,CAAC;wCACf,CAACN,YAAYI,IAAI,CAAC,EAAEJ,YAAYG,KAAK;oCACvC;oCACA,OAAOnB,MAAM,CAACgB,YAAYI,IAAI,CAAC;gCACjC,OAAO;oCACLpB,MAAM,CAACgB,YAAYI,IAAI,CAAC,GAAGJ,YAAYG,KAAK;gCAC9C;4BACF;wBACF,OAAO,IAAI,OAAOH,aAAaG,UAAU,UAAU;4BACjDnB,SAASZ,4BAA4BY,QAAQgB,YAAYG,KAAK,IAAI,CAAC,GAAG;gCACpE,6BAA6B;gCAC7BI,OAAO;4BACT;wBACF;oBACF;gBACF;YACF;QACF;IACF;IAEA,OAAOvB;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/db-mongodb",
3
- "version": "3.33.0-internal.d1efdd8",
3
+ "version": "3.34.0-canary.0",
4
4
  "description": "The officially supported MongoDB database adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -49,10 +49,10 @@
49
49
  "mongodb": "6.12.0",
50
50
  "mongodb-memory-server": "^10",
51
51
  "@payloadcms/eslint-config": "3.28.0",
52
- "payload": "3.33.0-internal.d1efdd8"
52
+ "payload": "3.34.0-canary.0"
53
53
  },
54
54
  "peerDependencies": {
55
- "payload": "3.33.0-internal.d1efdd8"
55
+ "payload": "3.34.0-canary.0"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "pnpm build:types && pnpm build:swc",