@payloadcms/db-mongodb 3.0.0-beta.2 → 3.0.0-beta.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAgB5C,eAAO,MAAM,IAAI,EAAE,IA+ElB,CAAA"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAgB5C,eAAO,MAAM,IAAI,EAAE,IAyElB,CAAA"}
package/dist/init.js CHANGED
@@ -37,11 +37,6 @@ export const init = function init() {
37
37
  config: collection
38
38
  }), schema, this.autoPluralization === true ? undefined : collection.slug);
39
39
  this.collections[collection.slug] = model;
40
- // TS expect error only needed until we launch 2.0.0
41
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
42
- this.payload.collections[collection.slug] = {
43
- config: collection
44
- };
45
40
  });
46
41
  const model = buildGlobalModel(this.payload.config);
47
42
  this.globals = model;
package/dist/init.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/init.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { PaginateOptions } from 'mongoose'\nimport type { Init } from 'payload/database'\nimport type { SanitizedCollectionConfig } from 'payload/types'\n\nimport mongoose from 'mongoose'\nimport paginate from 'mongoose-paginate-v2'\nimport { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload/versions'\n\nimport type { MongooseAdapter } from './index.js'\nimport type { CollectionModel } from './types.js'\n\nimport buildCollectionSchema from './models/buildCollectionSchema.js'\nimport { buildGlobalModel } from './models/buildGlobalModel.js'\nimport buildSchema from './models/buildSchema.js'\nimport getBuildQueryPlugin from './queries/buildQuery.js'\nimport { getDBName } from './utilities/getDBName.js'\n\nexport const init: Init = function init(this: MongooseAdapter) {\n this.payload.config.collections.forEach((collection: SanitizedCollectionConfig) => {\n const schema = buildCollectionSchema(collection, this.payload.config)\n\n if (collection.versions) {\n const versionModelName = getDBName({ config: collection, versions: true })\n\n const versionCollectionFields = buildVersionCollectionFields(collection)\n\n const versionSchema = buildSchema(this.payload.config, versionCollectionFields, {\n disableUnique: true,\n draftsEnabled: true,\n options: {\n minimize: false,\n timestamps: false,\n },\n })\n\n versionSchema.plugin<any, PaginateOptions>(paginate, { useEstimatedCount: true }).plugin(\n getBuildQueryPlugin({\n collectionSlug: collection.slug,\n versionsFields: versionCollectionFields,\n }),\n )\n\n const model = mongoose.model(\n versionModelName,\n versionSchema,\n this.autoPluralization === true ? undefined : versionModelName,\n ) as CollectionModel\n // this.payload.versions[collection.slug] = model;\n this.versions[collection.slug] = model\n }\n\n const model = mongoose.model(\n getDBName({ config: collection }),\n schema,\n this.autoPluralization === true ? undefined : collection.slug,\n ) as CollectionModel\n this.collections[collection.slug] = model\n\n // TS expect error only needed until we launch 2.0.0\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n this.payload.collections[collection.slug] = {\n config: collection,\n }\n })\n\n const model = buildGlobalModel(this.payload.config)\n this.globals = model\n\n this.payload.config.globals.forEach((global) => {\n if (global.versions) {\n const versionModelName = getDBName({ config: global, versions: true })\n\n const versionGlobalFields = buildVersionGlobalFields(global)\n\n const versionSchema = buildSchema(this.payload.config, versionGlobalFields, {\n disableUnique: true,\n draftsEnabled: true,\n indexSortableFields: this.payload.config.indexSortableFields,\n options: {\n minimize: false,\n timestamps: false,\n },\n })\n\n versionSchema\n .plugin<any, PaginateOptions>(paginate, { useEstimatedCount: true })\n .plugin(getBuildQueryPlugin({ versionsFields: versionGlobalFields }))\n\n const versionsModel = mongoose.model(\n versionModelName,\n versionSchema,\n versionModelName,\n ) as CollectionModel\n this.versions[global.slug] = versionsModel\n }\n })\n}\n"],"names":["mongoose","paginate","buildVersionCollectionFields","buildVersionGlobalFields","buildCollectionSchema","buildGlobalModel","buildSchema","getBuildQueryPlugin","getDBName","init","payload","config","collections","forEach","collection","schema","versions","versionModelName","versionCollectionFields","versionSchema","disableUnique","draftsEnabled","options","minimize","timestamps","plugin","useEstimatedCount","collectionSlug","slug","versionsFields","model","autoPluralization","undefined","globals","global","versionGlobalFields","indexSortableFields","versionsModel"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GAKpC,OAAOA,cAAc,WAAU;AAC/B,OAAOC,cAAc,uBAAsB;AAC3C,SAASC,4BAA4B,EAAEC,wBAAwB,QAAQ,mBAAkB;AAKzF,OAAOC,2BAA2B,oCAAmC;AACrE,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,OAAOC,iBAAiB,0BAAyB;AACjD,OAAOC,yBAAyB,0BAAyB;AACzD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,OAAa,SAASA;IACjC,IAAI,CAACC,OAAO,CAACC,MAAM,CAACC,WAAW,CAACC,OAAO,CAAC,CAACC;QACvC,MAAMC,SAASX,sBAAsBU,YAAY,IAAI,CAACJ,OAAO,CAACC,MAAM;QAEpE,IAAIG,WAAWE,QAAQ,EAAE;YACvB,MAAMC,mBAAmBT,UAAU;gBAAEG,QAAQG;gBAAYE,UAAU;YAAK;YAExE,MAAME,0BAA0BhB,6BAA6BY;YAE7D,MAAMK,gBAAgBb,YAAY,IAAI,CAACI,OAAO,CAACC,MAAM,EAAEO,yBAAyB;gBAC9EE,eAAe;gBACfC,eAAe;gBACfC,SAAS;oBACPC,UAAU;oBACVC,YAAY;gBACd;YACF;YAEAL,cAAcM,MAAM,CAAuBxB,UAAU;gBAAEyB,mBAAmB;YAAK,GAAGD,MAAM,CACtFlB,oBAAoB;gBAClBoB,gBAAgBb,WAAWc,IAAI;gBAC/BC,gBAAgBX;YAClB;YAGF,MAAMY,QAAQ9B,SAAS8B,KAAK,CAC1Bb,kBACAE,eACA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AAC"}
1
+ {"version":3,"sources":["../src/init.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { PaginateOptions } from 'mongoose'\nimport type { Init } from 'payload/database'\nimport type { SanitizedCollectionConfig } from 'payload/types'\n\nimport mongoose from 'mongoose'\nimport paginate from 'mongoose-paginate-v2'\nimport { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload/versions'\n\nimport type { MongooseAdapter } from './index.js'\nimport type { CollectionModel } from './types.js'\n\nimport buildCollectionSchema from './models/buildCollectionSchema.js'\nimport { buildGlobalModel } from './models/buildGlobalModel.js'\nimport buildSchema from './models/buildSchema.js'\nimport getBuildQueryPlugin from './queries/buildQuery.js'\nimport { getDBName } from './utilities/getDBName.js'\n\nexport const init: Init = function init(this: MongooseAdapter) {\n this.payload.config.collections.forEach((collection: SanitizedCollectionConfig) => {\n const schema = buildCollectionSchema(collection, this.payload.config)\n\n if (collection.versions) {\n const versionModelName = getDBName({ config: collection, versions: true })\n\n const versionCollectionFields = buildVersionCollectionFields(collection)\n\n const versionSchema = buildSchema(this.payload.config, versionCollectionFields, {\n disableUnique: true,\n draftsEnabled: true,\n options: {\n minimize: false,\n timestamps: false,\n },\n })\n\n versionSchema.plugin<any, PaginateOptions>(paginate, { useEstimatedCount: true }).plugin(\n getBuildQueryPlugin({\n collectionSlug: collection.slug,\n versionsFields: versionCollectionFields,\n }),\n )\n\n const model = mongoose.model(\n versionModelName,\n versionSchema,\n this.autoPluralization === true ? undefined : versionModelName,\n ) as CollectionModel\n // this.payload.versions[collection.slug] = model;\n this.versions[collection.slug] = model\n }\n\n const model = mongoose.model(\n getDBName({ config: collection }),\n schema,\n this.autoPluralization === true ? undefined : collection.slug,\n ) as CollectionModel\n this.collections[collection.slug] = model\n })\n\n const model = buildGlobalModel(this.payload.config)\n this.globals = model\n\n this.payload.config.globals.forEach((global) => {\n if (global.versions) {\n const versionModelName = getDBName({ config: global, versions: true })\n\n const versionGlobalFields = buildVersionGlobalFields(global)\n\n const versionSchema = buildSchema(this.payload.config, versionGlobalFields, {\n disableUnique: true,\n draftsEnabled: true,\n indexSortableFields: this.payload.config.indexSortableFields,\n options: {\n minimize: false,\n timestamps: false,\n },\n })\n\n versionSchema\n .plugin<any, PaginateOptions>(paginate, { useEstimatedCount: true })\n .plugin(getBuildQueryPlugin({ versionsFields: versionGlobalFields }))\n\n const versionsModel = mongoose.model(\n versionModelName,\n versionSchema,\n versionModelName,\n ) as CollectionModel\n this.versions[global.slug] = versionsModel\n }\n })\n}\n"],"names":["mongoose","paginate","buildVersionCollectionFields","buildVersionGlobalFields","buildCollectionSchema","buildGlobalModel","buildSchema","getBuildQueryPlugin","getDBName","init","payload","config","collections","forEach","collection","schema","versions","versionModelName","versionCollectionFields","versionSchema","disableUnique","draftsEnabled","options","minimize","timestamps","plugin","useEstimatedCount","collectionSlug","slug","versionsFields","model","autoPluralization","undefined","globals","global","versionGlobalFields","indexSortableFields","versionsModel"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GAKpC,OAAOA,cAAc,WAAU;AAC/B,OAAOC,cAAc,uBAAsB;AAC3C,SAASC,4BAA4B,EAAEC,wBAAwB,QAAQ,mBAAkB;AAKzF,OAAOC,2BAA2B,oCAAmC;AACrE,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,OAAOC,iBAAiB,0BAAyB;AACjD,OAAOC,yBAAyB,0BAAyB;AACzD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,OAAa,SAASA;IACjC,IAAI,CAACC,OAAO,CAACC,MAAM,CAACC,WAAW,CAACC,OAAO,CAAC,CAACC;QACvC,MAAMC,SAASX,sBAAsBU,YAAY,IAAI,CAACJ,OAAO,CAACC,MAAM;QAEpE,IAAIG,WAAWE,QAAQ,EAAE;YACvB,MAAMC,mBAAmBT,UAAU;gBAAEG,QAAQG;gBAAYE,UAAU;YAAK;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oBACVC,YAAY;gBACd;YACF;YAEAL,cACGM,MAAM,CAAuBxB,UAAU;gBAAEyB,mBAAmB;YAAK,GACjED,MAAM,CAAClB,oBAAoB;gBAAEsB,gBAAgBM;YAAoB;YAEpE,MAAME,gBAAgBrC,SAAS8B,KAAK,CAClCb,kBACAE,eACAF;YAEF,IAAI,CAACD,QAAQ,CAACkB,OAAON,IAAI,CAAC,GAAGS;QAC/B;IACF;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"buildSearchParams.d.ts","sourceRoot":"","sources":["../../src/queries/buildSearchParams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAiB1C,KAAK,WAAW,GAAG;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAOD;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,cAAc,EACd,MAAM,EACN,UAAU,EACV,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,OAAO,EACP,GAAG,GACJ,EAAE;IACD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,EAAE,OAAO,CAAA;CACb,GAAG,OAAO,CAAC,WAAW,CAAC,CA+NvB"}
1
+ {"version":3,"file":"buildSearchParams.d.ts","sourceRoot":"","sources":["../../src/queries/buildSearchParams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAiB1C,KAAK,WAAW,GAAG;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAOD;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,cAAc,EACd,MAAM,EACN,UAAU,EACV,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,OAAO,EACP,GAAG,GACJ,EAAE;IACD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,EAAE,OAAO,CAAA;CACb,GAAG,OAAO,CAAC,WAAW,CAAC,CAmNvB"}
@@ -1,7 +1,6 @@
1
1
  import ObjectIdImport from 'bson-objectid';
2
2
  import mongoose from 'mongoose';
3
3
  import { getLocalizedPaths } from 'payload/database';
4
- import { fieldAffectsData } from 'payload/types';
5
4
  import { validOperators } from 'payload/types';
6
5
  import { operatorMap } from './operatorMap.js';
7
6
  import { sanitizeQueryValue } from './sanitizeQueryValue.js';
@@ -19,12 +18,10 @@ const subQueryOptions = {
19
18
  let paths = [];
20
19
  let hasCustomID = false;
21
20
  if (sanitizedPath === '_id') {
22
- const customIDfield = payload.collections[collectionSlug]?.config.fields.find((field)=>fieldAffectsData(field) && field.name === 'id');
21
+ const customIDFieldType = payload.collections[collectionSlug]?.customIDType;
23
22
  let idFieldType = 'text';
24
- if (customIDfield) {
25
- if (customIDfield?.type === 'text' || customIDfield?.type === 'number') {
26
- idFieldType = customIDfield.type;
27
- }
23
+ if (customIDFieldType) {
24
+ idFieldType = customIDFieldType;
28
25
  hasCustomID = true;
29
26
  }
30
27
  paths.push({
@@ -157,11 +154,9 @@ const subQueryOptions = {
157
154
  (Array.isArray(field.relationTo) ? field.relationTo : [
158
155
  field.relationTo
159
156
  ]).forEach((relationTo)=>{
160
- const isRelatedToCustomNumberID = payload.collections[relationTo]?.config?.fields.find((relatedField)=>{
161
- return fieldAffectsData(relatedField) && relatedField.name === 'id' && relatedField.type === 'number';
162
- });
157
+ const isRelatedToCustomNumberID = payload.collections[relationTo]?.customIDType === 'number';
163
158
  if (isRelatedToCustomNumberID) {
164
- if (isRelatedToCustomNumberID.type === 'number') hasNumberIDRelation = true;
159
+ hasNumberIDRelation = true;
165
160
  }
166
161
  });
167
162
  if (hasNumberIDRelation) result.value.$or.push({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/queries/buildSearchParams.ts"],"sourcesContent":["import type { Payload } from 'payload'\nimport type { PathToQuery } from 'payload/database'\nimport type { Field } from 'payload/types'\nimport type { Operator } from 'payload/types'\n\nimport ObjectIdImport from 'bson-objectid'\nimport mongoose from 'mongoose'\nimport { getLocalizedPaths } from 'payload/database'\nimport { fieldAffectsData } from 'payload/types'\nimport { validOperators } from 'payload/types'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { operatorMap } from './operatorMap.js'\nimport { sanitizeQueryValue } from './sanitizeQueryValue.js'\n\nconst ObjectId = (ObjectIdImport.default ||\n ObjectIdImport) as unknown as typeof ObjectIdImport.default\n\ntype SearchParam = {\n path?: string\n rawQuery?: unknown\n value?: unknown\n}\n\nconst subQueryOptions = {\n lean: true,\n limit: 50,\n}\n\n/**\n * Convert the Payload key / value / operator into a MongoDB query\n */\nexport async function buildSearchParam({\n collectionSlug,\n fields,\n globalSlug,\n incomingPath,\n locale,\n operator,\n payload,\n val,\n}: {\n collectionSlug?: string\n fields: Field[]\n globalSlug?: string\n incomingPath: string\n locale?: string\n operator: string\n payload: Payload\n val: unknown\n}): Promise<SearchParam> {\n // Replace GraphQL nested field double underscore formatting\n let sanitizedPath = incomingPath.replace(/__/g, '.')\n if (sanitizedPath === 'id') sanitizedPath = '_id'\n\n let paths: PathToQuery[] = []\n\n let hasCustomID = false\n\n if (sanitizedPath === '_id') {\n const customIDfield = payload.collections[collectionSlug]?.config.fields.find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n let idFieldType: 'number' | 'text' = 'text'\n\n if (customIDfield) {\n if (customIDfield?.type === 'text' || customIDfield?.type === 'number') {\n idFieldType = customIDfield.type\n }\n\n hasCustomID = true\n }\n\n paths.push({\n collectionSlug,\n complete: true,\n field: {\n name: 'id',\n type: idFieldType,\n } as Field,\n path: '_id',\n })\n } else {\n paths = await getLocalizedPaths({\n collectionSlug,\n fields,\n globalSlug,\n incomingPath: sanitizedPath,\n locale,\n payload,\n })\n }\n\n const [{ field, path }] = paths\n\n if (path) {\n const {\n operator: formattedOperator,\n rawQuery,\n val: formattedValue,\n } = sanitizeQueryValue({\n field,\n hasCustomID,\n operator,\n path,\n val,\n })\n\n if (rawQuery) return { value: rawQuery }\n\n // If there are multiple collections to search through,\n // Recursively build up a list of query constraints\n if (paths.length > 1) {\n // Remove top collection and reverse array\n // to work backwards from top\n const pathsToQuery = paths.slice(1).reverse()\n\n const initialRelationshipQuery = {\n value: {},\n } as SearchParam\n\n const relationshipQuery = await pathsToQuery.reduce(\n async (priorQuery, { collectionSlug: slug, path: subPath }, i) => {\n const priorQueryResult = await priorQuery\n\n const SubModel = (payload.db as MongooseAdapter).collections[slug]\n\n // On the \"deepest\" collection,\n // Search on the value passed through the query\n if (i === 0) {\n const subQuery = await SubModel.buildQuery({\n locale,\n payload,\n where: {\n [subPath]: {\n [formattedOperator]: val,\n },\n },\n })\n\n const result = await SubModel.find(subQuery, subQueryOptions)\n\n const $in: unknown[] = []\n\n result.forEach((doc) => {\n const stringID = doc._id.toString()\n $in.push(stringID)\n\n if (mongoose.Types.ObjectId.isValid(stringID)) {\n $in.push(doc._id)\n }\n })\n\n if (pathsToQuery.length === 1) {\n return {\n path,\n value: { $in },\n }\n }\n\n const nextSubPath = pathsToQuery[i + 1].path\n\n return {\n value: { [nextSubPath]: { $in } },\n }\n }\n\n const subQuery = priorQueryResult.value\n const result = await SubModel.find(subQuery, subQueryOptions)\n\n const $in = result.map((doc) => doc._id.toString())\n\n // If it is the last recursion\n // then pass through the search param\n if (i + 1 === pathsToQuery.length) {\n return {\n path,\n value: { $in },\n }\n }\n\n return {\n value: {\n _id: { $in },\n },\n }\n },\n Promise.resolve(initialRelationshipQuery),\n )\n\n return relationshipQuery\n }\n\n if (formattedOperator && validOperators.includes(formattedOperator as Operator)) {\n const operatorKey = operatorMap[formattedOperator]\n\n if (field.type === 'relationship' || field.type === 'upload') {\n let hasNumberIDRelation\n\n const result = {\n value: {\n $or: [{ [path]: { [operatorKey]: formattedValue } }],\n },\n }\n\n if (typeof formattedValue === 'string') {\n if (mongoose.Types.ObjectId.isValid(formattedValue)) {\n result.value.$or.push({\n [path]: { [operatorKey]: new ObjectId(formattedValue) },\n })\n } else {\n ;(Array.isArray(field.relationTo) ? field.relationTo : [field.relationTo]).forEach(\n (relationTo) => {\n const isRelatedToCustomNumberID = payload.collections[\n relationTo\n ]?.config?.fields.find((relatedField) => {\n return (\n fieldAffectsData(relatedField) &&\n relatedField.name === 'id' &&\n relatedField.type === 'number'\n )\n })\n\n if (isRelatedToCustomNumberID) {\n if (isRelatedToCustomNumberID.type === 'number') hasNumberIDRelation = true\n }\n },\n )\n\n if (hasNumberIDRelation)\n result.value.$or.push({ [path]: { [operatorKey]: parseFloat(formattedValue) } })\n }\n }\n\n if (result.value.$or.length > 1) {\n return result\n }\n }\n\n if (formattedOperator === 'like' && typeof formattedValue === 'string') {\n const words = formattedValue.split(' ')\n\n const result = {\n value: {\n $and: words.map((word) => ({\n [path]: {\n $options: 'i',\n $regex: word.replace(/[\\\\^$*+?.()|[\\]{}]/g, '\\\\$&'),\n },\n })),\n },\n }\n\n return result\n }\n\n // Some operators like 'near' need to define a full query\n // so if there is no operator key, just return the value\n if (!operatorKey) {\n return {\n path,\n value: formattedValue,\n }\n }\n\n return {\n path,\n value: { [operatorKey]: formattedValue },\n }\n }\n }\n return undefined\n}\n"],"names":["ObjectIdImport","mongoose","getLocalizedPaths","fieldAffectsData","validOperators","operatorMap","sanitizeQueryValue","ObjectId","default","subQueryOptions","lean","limit","buildSearchParam","collectionSlug","fields","globalSlug","incomingPath","locale","operator","payload","val","sanitizedPath","replace","paths","hasCustomID","customIDfield","collections","config","find","field","name","idFieldType","type","push","complete","path","formattedOperator","rawQuery","formattedValue","value","length","pathsToQuery","slice","reverse","initialRelationshipQuery","relationshipQuery","reduce","priorQuery","slug","subPath","i","priorQueryResult","SubModel","db","subQuery","buildQuery","where","result","$in","forEach","doc","stringID","_id","toString","Types","isValid","nextSubPath","map","Promise","resolve","includes","operatorKey","hasNumberIDRelation","$or","Array","isArray","relationTo","isRelatedToCustomNumberID","relatedField","parseFloat","words","split","$and","word","$options","$regex","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,OAAOA,oBAAoB,gBAAe;AAC1C,OAAOC,cAAc,WAAU;AAC/B,SAASC,iBAAiB,QAAQ,mBAAkB;AACpD,SAASC,gBAAgB,QAAQ,gBAAe;AAChD,SAASC,cAAc,QAAQ,gBAAe;AAI9C,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,kBAAkB,QAAQ,0BAAyB;AAE5D,MAAMC,WAAYP,eAAeQ,OAAO,IACtCR;AAQF,MAAMS,kBAAkB;IACtBC,MAAM;IACNC,OAAO;AACT;AAEA;;CAEC,GACD,OAAO,eAAeC,iBAAiB,EACrCC,cAAc,E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F,IAAIA,qBACFf,OAAOlB,KAAK,CAACkC,GAAG,CAACxC,IAAI,CAAC;4BAAE,CAACE,KAAK,EAAE;gCAAE,CAACoC,YAAY,EAAEQ,WAAWzC;4BAAgB;wBAAE;oBAClF;gBACF;gBAEA,IAAImB,OAAOlB,KAAK,CAACkC,GAAG,CAACjC,MAAM,GAAG,GAAG;oBAC/B,OAAOiB;gBACT;YACF;YAEA,IAAIrB,sBAAsB,UAAU,OAAOE,mBAAmB,UAAU;gBACtE,MAAM0C,QAAQ1C,eAAe2C,KAAK,CAAC;gBAEnC,MAAMxB,SAAS;oBACblB,OAAO;wBACL2C,MAAMF,MAAMb,GAAG,CAAC,CAACgB,OAAU,CAAA;gCACzB,CAAChD,KAAK,EAAE;oCACNiD,UAAU;oCACVC,QAAQF,KAAK7D,OAAO,CAAC,uBAAuB;gCAC9C;4BACF,CAAA;oBACF;gBACF;gBAEA,OAAOmC;YACT;YAEA,yDAAyD;YACzD,wDAAwD;YACxD,IAAI,CAACc,aAAa;gBAChB,OAAO;oBACLpC;oBACAI,OAAOD;gBACT;YACF;YAEA,OAAO;gBACLH;gBACAI,OAAO;oBAAE,CAACgC,YAAY,EAAEjC;gBAAe;YACzC;QACF;IACF;IACA,OAAOgD;AACT"}
1
+ {"version":3,"sources":["../../src/queries/buildSearchParams.ts"],"sourcesContent":["import type { Payload } from 'payload'\nimport type { PathToQuery } from 'payload/database'\nimport type { Field } from 'payload/types'\nimport type { Operator } from 'payload/types'\n\nimport ObjectIdImport from 'bson-objectid'\nimport mongoose from 'mongoose'\nimport { getLocalizedPaths } from 'payload/database'\nimport { fieldAffectsData } from 'payload/types'\nimport { validOperators } from 'payload/types'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { operatorMap } from './operatorMap.js'\nimport { sanitizeQueryValue } from './sanitizeQueryValue.js'\n\nconst ObjectId = (ObjectIdImport.default ||\n ObjectIdImport) as unknown as typeof ObjectIdImport.default\n\ntype SearchParam = {\n path?: string\n rawQuery?: unknown\n value?: unknown\n}\n\nconst subQueryOptions = {\n lean: true,\n limit: 50,\n}\n\n/**\n * Convert the Payload key / value / operator into a MongoDB query\n */\nexport async function buildSearchParam({\n collectionSlug,\n fields,\n globalSlug,\n incomingPath,\n locale,\n operator,\n payload,\n val,\n}: {\n collectionSlug?: string\n fields: Field[]\n globalSlug?: string\n incomingPath: string\n locale?: string\n operator: string\n payload: Payload\n val: unknown\n}): Promise<SearchParam> {\n // Replace GraphQL nested field double underscore formatting\n let sanitizedPath = incomingPath.replace(/__/g, '.')\n if (sanitizedPath === 'id') sanitizedPath = '_id'\n\n let paths: PathToQuery[] = []\n\n let hasCustomID = false\n\n if (sanitizedPath === '_id') {\n const customIDFieldType = payload.collections[collectionSlug]?.customIDType\n\n let idFieldType: 'number' | 'text' = 'text'\n\n if (customIDFieldType) {\n idFieldType = customIDFieldType\n hasCustomID = true\n }\n\n paths.push({\n collectionSlug,\n complete: true,\n field: {\n name: 'id',\n type: idFieldType,\n } as Field,\n path: '_id',\n })\n } else {\n paths = await getLocalizedPaths({\n collectionSlug,\n fields,\n globalSlug,\n incomingPath: sanitizedPath,\n locale,\n payload,\n })\n }\n\n const [{ field, path }] = paths\n\n if (path) {\n const {\n operator: formattedOperator,\n rawQuery,\n val: formattedValue,\n } = sanitizeQueryValue({\n field,\n hasCustomID,\n operator,\n path,\n val,\n })\n\n if (rawQuery) return { value: rawQuery }\n\n // If there are multiple collections to search through,\n // Recursively build up a list of query constraints\n if (paths.length > 1) {\n // Remove top collection and reverse array\n // to work backwards from top\n const pathsToQuery = paths.slice(1).reverse()\n\n const initialRelationshipQuery = {\n value: {},\n } as SearchParam\n\n const relationshipQuery = await pathsToQuery.reduce(\n async (priorQuery, { collectionSlug: slug, path: subPath }, i) => {\n const priorQueryResult = await priorQuery\n\n const SubModel = (payload.db as MongooseAdapter).collections[slug]\n\n // On the \"deepest\" collection,\n // Search on the value passed through the query\n if (i === 0) {\n const subQuery = await SubModel.buildQuery({\n locale,\n payload,\n where: {\n [subPath]: {\n [formattedOperator]: val,\n },\n },\n })\n\n const result = await SubModel.find(subQuery, subQueryOptions)\n\n const $in: unknown[] = []\n\n result.forEach((doc) => {\n const stringID = doc._id.toString()\n $in.push(stringID)\n\n if (mongoose.Types.ObjectId.isValid(stringID)) {\n $in.push(doc._id)\n }\n })\n\n if (pathsToQuery.length === 1) {\n return {\n path,\n value: { $in },\n }\n }\n\n const nextSubPath = pathsToQuery[i + 1].path\n\n return {\n value: { [nextSubPath]: { $in } },\n }\n }\n\n const subQuery = priorQueryResult.value\n const result = await SubModel.find(subQuery, subQueryOptions)\n\n const $in = result.map((doc) => doc._id.toString())\n\n // If it is the last recursion\n // then pass through the search param\n if (i + 1 === pathsToQuery.length) {\n return {\n path,\n value: { $in },\n }\n }\n\n return {\n value: {\n _id: { $in },\n },\n }\n },\n Promise.resolve(initialRelationshipQuery),\n )\n\n return relationshipQuery\n }\n\n if (formattedOperator && validOperators.includes(formattedOperator as Operator)) {\n const operatorKey = operatorMap[formattedOperator]\n\n if (field.type === 'relationship' || field.type === 'upload') {\n let hasNumberIDRelation\n\n const result = {\n value: {\n $or: [{ [path]: { [operatorKey]: formattedValue } }],\n },\n }\n\n if (typeof formattedValue === 'string') {\n if (mongoose.Types.ObjectId.isValid(formattedValue)) {\n result.value.$or.push({\n [path]: { [operatorKey]: new ObjectId(formattedValue) },\n })\n } else {\n ;(Array.isArray(field.relationTo) ? field.relationTo : [field.relationTo]).forEach(\n (relationTo) => {\n const isRelatedToCustomNumberID =\n payload.collections[relationTo]?.customIDType === 'number'\n\n if (isRelatedToCustomNumberID) {\n hasNumberIDRelation = true\n }\n },\n )\n\n if (hasNumberIDRelation)\n result.value.$or.push({ [path]: { [operatorKey]: parseFloat(formattedValue) } })\n }\n }\n\n if (result.value.$or.length > 1) {\n return result\n }\n }\n\n if (formattedOperator === 'like' && typeof formattedValue === 'string') {\n const words = formattedValue.split(' ')\n\n const result = {\n value: {\n $and: words.map((word) => ({\n [path]: {\n $options: 'i',\n $regex: word.replace(/[\\\\^$*+?.()|[\\]{}]/g, '\\\\$&'),\n },\n })),\n },\n }\n\n return result\n }\n\n // Some operators like 'near' need to define a full query\n // so if there is no operator key, just return the value\n if (!operatorKey) {\n return {\n path,\n value: formattedValue,\n }\n }\n\n return {\n path,\n value: { [operatorKey]: formattedValue },\n }\n }\n }\n return undefined\n}\n"],"names":["ObjectIdImport","mongoose","getLocalizedPaths","validOperators","operatorMap","sanitizeQueryValue","ObjectId","default","subQueryOptions","lean","limit","buildSearchParam","collectionSlug","fields","globalSlug","incomingPath","locale","operator","payload","val","sanitizedPath","replace","paths","hasCustomID","customIDFieldType","collections","customIDType","idFieldType","push","complete","field","name","type","path","formattedOperator","rawQuery","formattedValue","value","length","pathsToQuery","slice","reverse","initialRelationshipQuery","relationshipQuery","reduce","priorQuery","slug","subPath","i","priorQueryResult","SubModel","db","subQuery","buildQuery","where","result","find","$in","forEach","doc","stringID","_id","toString","Types","isValid","nextSubPath","map","Promise","resolve","includes","operatorKey","hasNumberIDRelation","$or","Array","isArray","relationTo","isRelatedToCustomNumberID","parseFloat","words","split","$and","word","$options","$regex","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,OAAOA,oBAAoB,gBAAe;AAC1C,OAAOC,cAAc,WAAU;AAC/B,SAASC,iBAAiB,QAAQ,mBAAkB;AAEpD,SAASC,cAAc,QAAQ,gBAAe;AAI9C,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,kBAAkB,QAAQ,0BAAyB;AAE5D,MAAMC,WAAYN,eAAeO,OAAO,IACtCP;AAQF,MAAMQ,kBAAkB;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AG;oBAC/B,OAAOiB;gBACT;YACF;YAEA,IAAIrB,sBAAsB,UAAU,OAAOE,mBAAmB,UAAU;gBACtE,MAAM0C,QAAQ1C,eAAe2C,KAAK,CAAC;gBAEnC,MAAMxB,SAAS;oBACblB,OAAO;wBACL2C,MAAMF,MAAMZ,GAAG,CAAC,CAACe,OAAU,CAAA;gCACzB,CAAChD,KAAK,EAAE;oCACNiD,UAAU;oCACVC,QAAQF,KAAK5D,OAAO,CAAC,uBAAuB;gCAC9C;4BACF,CAAA;oBACF;gBACF;gBAEA,OAAOkC;YACT;YAEA,yDAAyD;YACzD,wDAAwD;YACxD,IAAI,CAACe,aAAa;gBAChB,OAAO;oBACLrC;oBACAI,OAAOD;gBACT;YACF;YAEA,OAAO;gBACLH;gBACAI,OAAO;oBAAE,CAACiC,YAAY,EAAElC;gBAAe;YACzC;QACF;IACF;IACA,OAAOgD;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/db-mongodb",
3
- "version": "3.0.0-beta.2",
3
+ "version": "3.0.0-beta.4",
4
4
  "description": "The officially supported MongoDB database adapter for Payload",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,11 +31,11 @@
31
31
  "@types/mongoose-aggregate-paginate-v2": "1.0.9",
32
32
  "mongodb": "4.17.1",
33
33
  "mongodb-memory-server": "^9",
34
- "payload": "3.0.0-beta.2",
35
- "@payloadcms/eslint-config": "1.1.1"
34
+ "@payloadcms/eslint-config": "1.1.1",
35
+ "payload": "3.0.0-beta.4"
36
36
  },
37
37
  "peerDependencies": {
38
- "payload": "3.0.0-beta.2"
38
+ "payload": "3.0.0-beta.4"
39
39
  },
40
40
  "exports": {
41
41
  ".": {