@payloadcms/db-mongodb 3.24.0-canary.7d9fbaf → 3.24.0-canary.a62d86f
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.
- package/dist/count.d.ts.map +1 -1
- package/dist/count.js +5 -2
- package/dist/count.js.map +1 -1
- package/dist/countGlobalVersions.d.ts.map +1 -1
- package/dist/countGlobalVersions.js +5 -3
- package/dist/countGlobalVersions.js.map +1 -1
- package/dist/countVersions.d.ts.map +1 -1
- package/dist/countVersions.js +5 -3
- package/dist/countVersions.js.map +1 -1
- package/dist/deleteMany.d.ts.map +1 -1
- package/dist/deleteMany.js +5 -2
- package/dist/deleteMany.js.map +1 -1
- package/dist/deleteOne.d.ts.map +1 -1
- package/dist/deleteOne.js +9 -3
- package/dist/deleteOne.js.map +1 -1
- package/dist/deleteVersions.d.ts +1 -1
- package/dist/deleteVersions.d.ts.map +1 -1
- package/dist/deleteVersions.js +5 -2
- package/dist/deleteVersions.js.map +1 -1
- package/dist/find.d.ts.map +1 -1
- package/dist/find.js +5 -3
- package/dist/find.js.map +1 -1
- package/dist/findGlobal.d.ts.map +1 -1
- package/dist/findGlobal.js +6 -3
- package/dist/findGlobal.js.map +1 -1
- package/dist/findGlobalVersions.d.ts.map +1 -1
- package/dist/findGlobalVersions.js +4 -4
- package/dist/findGlobalVersions.js.map +1 -1
- package/dist/findOne.d.ts.map +1 -1
- package/dist/findOne.js +5 -2
- package/dist/findOne.js.map +1 -1
- package/dist/findVersions.d.ts.map +1 -1
- package/dist/findVersions.js +6 -4
- package/dist/findVersions.js.map +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +1 -3
- package/dist/init.js.map +1 -1
- package/dist/models/buildCollectionSchema.d.ts.map +1 -1
- package/dist/models/buildCollectionSchema.js +2 -3
- package/dist/models/buildCollectionSchema.js.map +1 -1
- package/dist/models/buildGlobalModel.d.ts.map +1 -1
- package/dist/models/buildGlobalModel.js +1 -2
- package/dist/models/buildGlobalModel.js.map +1 -1
- package/dist/queries/buildQuery.d.ts +6 -9
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/buildQuery.js +11 -35
- package/dist/queries/buildQuery.js.map +1 -1
- package/dist/queries/buildSortParam.d.ts +1 -1
- package/dist/queries/buildSortParam.d.ts.map +1 -1
- package/dist/queries/buildSortParam.js.map +1 -1
- package/dist/queries/getBuildQueryPlugin.d.ts +14 -0
- package/dist/queries/getBuildQueryPlugin.d.ts.map +1 -0
- package/dist/queries/getBuildQueryPlugin.js +40 -0
- package/dist/queries/getBuildQueryPlugin.js.map +1 -0
- package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
- package/dist/queries/sanitizeQueryValue.js.map +1 -1
- package/dist/queryDrafts.d.ts.map +1 -1
- package/dist/queryDrafts.js +6 -4
- package/dist/queryDrafts.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/updateGlobal.d.ts.map +1 -1
- package/dist/updateGlobal.js +3 -0
- package/dist/updateGlobal.js.map +1 -1
- package/dist/updateGlobalVersion.d.ts.map +1 -1
- package/dist/updateGlobalVersion.js +9 -3
- package/dist/updateGlobalVersion.js.map +1 -1
- package/dist/updateOne.d.ts.map +1 -1
- package/dist/updateOne.js +8 -2
- package/dist/updateOne.js.map +1 -1
- package/dist/updateVersion.d.ts.map +1 -1
- package/dist/updateVersion.js +9 -3
- package/dist/updateVersion.js.map +1 -1
- package/dist/utilities/buildJoinAggregation.d.ts.map +1 -1
- package/dist/utilities/buildJoinAggregation.js +150 -4
- package/dist/utilities/buildJoinAggregation.js.map +1 -1
- package/dist/utilities/buildProjectionFromSelect.d.ts.map +1 -1
- package/dist/utilities/buildProjectionFromSelect.js +14 -16
- package/dist/utilities/buildProjectionFromSelect.js.map +1 -1
- package/package.json +3 -3
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,KAAK,EACL,aAAa,EACb,aAAa,EACd,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,KAAK,EACL,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,OAAO,EACP,cAAc,EACd,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,QAAQ,EACR,eAAe,EACf,WAAW,EACX,SAAS,EACT,aAAa,EACb,SAAS,EACT,WAAW,EACZ,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,KAAK,EACL,aAAa,EACb,aAAa,EACd,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,KAAK,EACL,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,OAAO,EACP,cAAc,EACd,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,QAAQ,EACR,eAAe,EACf,WAAW,EACX,SAAS,EACT,aAAa,EACb,SAAS,EACT,WAAW,EACZ,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AAEtE,MAAM,WAAW,eACf,SAAQ,KAAK,CAAC,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OAAO,EAAE,WAAW,CAAC,CAAA;IACpD,IAAI,EAAE,sBAAsB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAChD,IAAI,EAAE,sBAAsB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAChD,QAAQ,EAAE,sBAAsB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAA;IACxD,MAAM,EAAE,sBAAsB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;CACrD,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;;;;;;;;OAWG;IACH,OAAO,EAAE,OAAO,CAAA;IAChB;;OAEG;IACH,GAAG,EAAE,cAAc,CAAA;IACnB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB,CAAA;AACD,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;;;;;;;OAWG;IACH,OAAO,EAAE,OAAO,CAAA;IAChB;;OAEG;IACH,GAAG,EAAE,cAAc,CAAA;IACnB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB,CAAA"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { ClientSession } from 'mongodb'\nimport type {\n AggregatePaginateModel,\n IndexDefinition,\n IndexOptions,\n Model,\n PaginateModel,\n SchemaOptions,\n} from 'mongoose'\nimport type {\n ArrayField,\n BlocksField,\n CheckboxField,\n CodeField,\n CollapsibleField,\n DateField,\n EmailField,\n Field,\n GroupField,\n JoinField,\n JSONField,\n NumberField,\n Payload,\n PayloadRequest,\n PointField,\n RadioField,\n RelationshipField,\n RichTextField,\n RowField,\n SanitizedConfig,\n SelectField,\n TabsField,\n TextareaField,\n TextField,\n UploadField,\n} from 'payload'\n\nimport type { BuildQueryArgs } from './queries/
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { ClientSession } from 'mongodb'\nimport type {\n AggregatePaginateModel,\n IndexDefinition,\n IndexOptions,\n Model,\n PaginateModel,\n SchemaOptions,\n} from 'mongoose'\nimport type {\n ArrayField,\n BlocksField,\n CheckboxField,\n CodeField,\n CollapsibleField,\n DateField,\n EmailField,\n Field,\n GroupField,\n JoinField,\n JSONField,\n NumberField,\n Payload,\n PayloadRequest,\n PointField,\n RadioField,\n RelationshipField,\n RichTextField,\n RowField,\n SanitizedConfig,\n SelectField,\n TabsField,\n TextareaField,\n TextField,\n UploadField,\n} from 'payload'\n\nimport type { BuildQueryArgs } from './queries/getBuildQueryPlugin.js'\n\nexport interface CollectionModel\n extends Model<any>,\n PaginateModel<any>,\n AggregatePaginateModel<any> {\n /** buildQuery is used to transform payload's where operator into what can be used by mongoose (e.g. id => _id) */\n buildQuery: (args: BuildQueryArgs) => Promise<Record<string, unknown>> // TODO: Delete this\n}\n\nexport interface AuthCollectionModel extends CollectionModel {\n resetPasswordExpiration: Date\n resetPasswordToken: string\n}\n\nexport type TypeOfIndex = {\n fields: IndexDefinition\n options?: IndexOptions\n}\n\nexport interface GlobalModel extends Model<Document> {\n buildQuery: (query: unknown, locale?: string) => Promise<Record<string, unknown>>\n}\n\nexport type BuildSchema<TSchema> = (args: {\n config: SanitizedConfig\n fields: Field[]\n options: BuildSchemaOptions\n}) => TSchema\n\nexport type BuildSchemaOptions = {\n allowIDField?: boolean\n disableUnique?: boolean\n draftsEnabled?: boolean\n indexSortableFields?: boolean\n options?: SchemaOptions\n}\n\nexport type FieldGenerator<TSchema, TField> = {\n config: SanitizedConfig\n field: TField\n options: BuildSchemaOptions\n schema: TSchema\n}\n\nexport type FieldGeneratorFunction<TSchema, TField extends Field> = (\n args: FieldGenerator<TSchema, TField>,\n) => void\n\n/**\n * Object mapping types to a schema based on TSchema\n */\nexport type FieldToSchemaMap<TSchema> = {\n array: FieldGeneratorFunction<TSchema, ArrayField>\n blocks: FieldGeneratorFunction<TSchema, BlocksField>\n checkbox: FieldGeneratorFunction<TSchema, CheckboxField>\n code: FieldGeneratorFunction<TSchema, CodeField>\n collapsible: FieldGeneratorFunction<TSchema, CollapsibleField>\n date: FieldGeneratorFunction<TSchema, DateField>\n email: FieldGeneratorFunction<TSchema, EmailField>\n group: FieldGeneratorFunction<TSchema, GroupField>\n join: FieldGeneratorFunction<TSchema, JoinField>\n json: FieldGeneratorFunction<TSchema, JSONField>\n number: FieldGeneratorFunction<TSchema, NumberField>\n point: FieldGeneratorFunction<TSchema, PointField>\n radio: FieldGeneratorFunction<TSchema, RadioField>\n relationship: FieldGeneratorFunction<TSchema, RelationshipField>\n richText: FieldGeneratorFunction<TSchema, RichTextField>\n row: FieldGeneratorFunction<TSchema, RowField>\n select: FieldGeneratorFunction<TSchema, SelectField>\n tabs: FieldGeneratorFunction<TSchema, TabsField>\n text: FieldGeneratorFunction<TSchema, TextField>\n textarea: FieldGeneratorFunction<TSchema, TextareaField>\n upload: FieldGeneratorFunction<TSchema, UploadField>\n}\n\nexport type MigrateUpArgs = {\n /**\n * The Payload instance that you can use to execute Local API methods\n * To use the current transaction you must pass `req` to arguments\n * @example\n * ```ts\n * import { type MigrateUpArgs } from '@payloadcms/db-mongodb'\n *\n * export async function up({ session, payload, req }: MigrateUpArgs): Promise<void> {\n * const posts = await payload.find({ collection: 'posts', req })\n * }\n * ```\n */\n payload: Payload\n /**\n * The `PayloadRequest` object that contains the current transaction\n */\n req: PayloadRequest\n /**\n * The MongoDB client session that you can use to execute MongoDB methods directly within the current transaction.\n * @example\n * ```ts\n * import { type MigrateUpArgs } from '@payloadcms/db-mongodb'\n *\n * export async function up({ session, payload, req }: MigrateUpArgs): Promise<void> {\n * const { rows: posts } = await payload.db.collections.posts.collection.find({ session }).toArray()\n * }\n * ```\n */\n session?: ClientSession\n}\nexport type MigrateDownArgs = {\n /**\n * The Payload instance that you can use to execute Local API methods\n * To use the current transaction you must pass `req` to arguments\n * @example\n * ```ts\n * import { type MigrateDownArgs } from '@payloadcms/db-mongodb'\n *\n * export async function down({ session, payload, req }: MigrateDownArgs): Promise<void> {\n * const posts = await payload.find({ collection: 'posts', req })\n * }\n * ```\n */\n payload: Payload\n /**\n * The `PayloadRequest` object that contains the current transaction\n */\n req: PayloadRequest\n /**\n * The MongoDB client session that you can use to execute MongoDB methods directly within the current transaction.\n * @example\n * ```ts\n * import { type MigrateDownArgs } from '@payloadcms/db-mongodb'\n *\n * export async function down({ session, payload, req }: MigrateDownArgs): Promise<void> {\n * const { rows: posts } = await payload.db.collections.posts.collection.find({ session }).toArray()\n * }\n * ```\n */\n session?: ClientSession\n}\n"],"names":[],"mappings":"AAgJA,WA8BC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateGlobal.d.ts","sourceRoot":"","sources":["../src/updateGlobal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAS3C,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"updateGlobal.d.ts","sourceRoot":"","sources":["../src/updateGlobal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAS3C,eAAO,MAAM,YAAY,EAAE,YAwC1B,CAAA"}
|
package/dist/updateGlobal.js
CHANGED
|
@@ -25,6 +25,9 @@ export const updateGlobal = async function updateGlobal({ slug, data, options: o
|
|
|
25
25
|
result = await Model.findOneAndUpdate({
|
|
26
26
|
globalType: slug
|
|
27
27
|
}, sanitizedData, options);
|
|
28
|
+
if (!result) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
28
31
|
result = JSON.parse(JSON.stringify(result));
|
|
29
32
|
// custom id type reset
|
|
30
33
|
result.id = result._id;
|
package/dist/updateGlobal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/updateGlobal.ts"],"sourcesContent":["import type { QueryOptions } from 'mongoose'\nimport type { UpdateGlobal } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\n\nexport const updateGlobal: UpdateGlobal = async function updateGlobal(\n this: MongooseAdapter,\n { slug, data, options: optionsArgs = {}, req, select },\n) {\n const Model = this.globals\n const fields = this.payload.config.globals.find((global) => global.slug === slug).fields\n\n const options: QueryOptions = {\n ...optionsArgs,\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: this.payload.config.globals.find((global) => global.slug === slug).flattenedFields,\n select,\n }),\n session: await getSession(this, req),\n }\n\n let result\n\n const sanitizedData = sanitizeRelationshipIDs({\n config: this.payload.config,\n data,\n fields,\n })\n\n result = await Model.findOneAndUpdate({ globalType: slug }, sanitizedData, options)\n\n result = JSON.parse(JSON.stringify(result))\n\n // custom id type reset\n result.id = result._id\n result = sanitizeInternalFields(result)\n\n return result\n}\n"],"names":["buildProjectionFromSelect","getSession","sanitizeInternalFields","sanitizeRelationshipIDs","updateGlobal","slug","data","options","optionsArgs","req","select","Model","globals","fields","payload","config","find","global","lean","new","projection","adapter","flattenedFields","session","result","sanitizedData","findOneAndUpdate","globalType","JSON","parse","stringify","id","_id"],"mappings":"AAKA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,sBAAsB,QAAQ,wCAAuC;AAC9E,SAASC,uBAAuB,QAAQ,yCAAwC;AAEhF,OAAO,MAAMC,eAA6B,eAAeA,aAEvD,EAAEC,IAAI,EAAEC,IAAI,EAAEC,SAASC,cAAc,CAAC,CAAC,EAAEC,GAAG,EAAEC,MAAM,EAAE;IAEtD,MAAMC,QAAQ,IAAI,CAACC,OAAO;IAC1B,MAAMC,SAAS,IAAI,CAACC,OAAO,CAACC,MAAM,CAACH,OAAO,CAACI,IAAI,CAAC,CAACC,SAAWA,OAAOZ,IAAI,KAAKA,MAAMQ,MAAM;IAExF,MAAMN,UAAwB;QAC5B,GAAGC,WAAW;QACdU,MAAM;QACNC,KAAK;QACLC,YAAYpB,0BAA0B;YACpCqB,SAAS,IAAI;YACbR,QAAQ,IAAI,CAACC,OAAO,CAACC,MAAM,CAACH,OAAO,CAACI,IAAI,CAAC,CAACC,SAAWA,OAAOZ,IAAI,KAAKA,MAAMiB,eAAe;YAC1FZ;QACF;QACAa,SAAS,MAAMtB,WAAW,IAAI,EAAEQ;IAClC;IAEA,IAAIe;IAEJ,MAAMC,gBAAgBtB,wBAAwB;QAC5CY,QAAQ,IAAI,CAACD,OAAO,CAACC,MAAM;QAC3BT;QACAO;IACF;IAEAW,SAAS,MAAMb,MAAMe,gBAAgB,CAAC;QAAEC,YAAYtB;IAAK,GAAGoB,eAAelB;
|
|
1
|
+
{"version":3,"sources":["../src/updateGlobal.ts"],"sourcesContent":["import type { QueryOptions } from 'mongoose'\nimport type { UpdateGlobal } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\n\nexport const updateGlobal: UpdateGlobal = async function updateGlobal(\n this: MongooseAdapter,\n { slug, data, options: optionsArgs = {}, req, select },\n) {\n const Model = this.globals\n const fields = this.payload.config.globals.find((global) => global.slug === slug).fields\n\n const options: QueryOptions = {\n ...optionsArgs,\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: this.payload.config.globals.find((global) => global.slug === slug).flattenedFields,\n select,\n }),\n session: await getSession(this, req),\n }\n\n let result\n\n const sanitizedData = sanitizeRelationshipIDs({\n config: this.payload.config,\n data,\n fields,\n })\n\n result = await Model.findOneAndUpdate({ globalType: slug }, sanitizedData, options)\n\n if (!result) {\n return null\n }\n\n result = JSON.parse(JSON.stringify(result))\n\n // custom id type reset\n result.id = result._id\n result = sanitizeInternalFields(result)\n\n return result\n}\n"],"names":["buildProjectionFromSelect","getSession","sanitizeInternalFields","sanitizeRelationshipIDs","updateGlobal","slug","data","options","optionsArgs","req","select","Model","globals","fields","payload","config","find","global","lean","new","projection","adapter","flattenedFields","session","result","sanitizedData","findOneAndUpdate","globalType","JSON","parse","stringify","id","_id"],"mappings":"AAKA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,sBAAsB,QAAQ,wCAAuC;AAC9E,SAASC,uBAAuB,QAAQ,yCAAwC;AAEhF,OAAO,MAAMC,eAA6B,eAAeA,aAEvD,EAAEC,IAAI,EAAEC,IAAI,EAAEC,SAASC,cAAc,CAAC,CAAC,EAAEC,GAAG,EAAEC,MAAM,EAAE;IAEtD,MAAMC,QAAQ,IAAI,CAACC,OAAO;IAC1B,MAAMC,SAAS,IAAI,CAACC,OAAO,CAACC,MAAM,CAACH,OAAO,CAACI,IAAI,CAAC,CAACC,SAAWA,OAAOZ,IAAI,KAAKA,MAAMQ,MAAM;IAExF,MAAMN,UAAwB;QAC5B,GAAGC,WAAW;QACdU,MAAM;QACNC,KAAK;QACLC,YAAYpB,0BAA0B;YACpCqB,SAAS,IAAI;YACbR,QAAQ,IAAI,CAACC,OAAO,CAACC,MAAM,CAACH,OAAO,CAACI,IAAI,CAAC,CAACC,SAAWA,OAAOZ,IAAI,KAAKA,MAAMiB,eAAe;YAC1FZ;QACF;QACAa,SAAS,MAAMtB,WAAW,IAAI,EAAEQ;IAClC;IAEA,IAAIe;IAEJ,MAAMC,gBAAgBtB,wBAAwB;QAC5CY,QAAQ,IAAI,CAACD,OAAO,CAACC,MAAM;QAC3BT;QACAO;IACF;IAEAW,SAAS,MAAMb,MAAMe,gBAAgB,CAAC;QAAEC,YAAYtB;IAAK,GAAGoB,eAAelB;IAE3E,IAAI,CAACiB,QAAQ;QACX,OAAO;IACT;IAEAA,SAASI,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACN;IAEnC,uBAAuB;IACvBA,OAAOO,EAAE,GAAGP,OAAOQ,GAAG;IACtBR,SAAStB,uBAAuBsB;IAEhC,OAAOA;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateGlobalVersion.d.ts","sourceRoot":"","sources":["../src/updateGlobalVersion.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,KAAK,UAAU,EAAE,KAAK,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAEjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"updateGlobalVersion.d.ts","sourceRoot":"","sources":["../src/updateGlobalVersion.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,KAAK,UAAU,EAAE,KAAK,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAEjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAOjD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAC5D,IAAI,EAAE,eAAe,EACrB,EACE,EAAE,EACF,MAAM,EAAE,UAAU,EAClB,MAAM,EACN,OAAO,EAAE,WAAgB,EACzB,GAAG,EACH,MAAM,EACN,WAAW,EACX,KAAK,GACN,EAAE,uBAAuB,CAAC,CAAC,CAAC,gBAiD9B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { buildVersionGlobalFields } from 'payload';
|
|
2
|
+
import { buildQuery } from './queries/buildQuery.js';
|
|
2
3
|
import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js';
|
|
3
4
|
import { getSession } from './utilities/getSession.js';
|
|
4
5
|
import { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js';
|
|
@@ -11,20 +12,22 @@ export async function updateGlobalVersion({ id, global: globalSlug, locale, opti
|
|
|
11
12
|
};
|
|
12
13
|
const currentGlobal = this.payload.config.globals.find((global)=>global.slug === globalSlug);
|
|
13
14
|
const fields = buildVersionGlobalFields(this.payload.config, currentGlobal);
|
|
15
|
+
const flattenedFields = buildVersionGlobalFields(this.payload.config, currentGlobal, true);
|
|
14
16
|
const options = {
|
|
15
17
|
...optionsArgs,
|
|
16
18
|
lean: true,
|
|
17
19
|
new: true,
|
|
18
20
|
projection: buildProjectionFromSelect({
|
|
19
21
|
adapter: this,
|
|
20
|
-
fields:
|
|
22
|
+
fields: flattenedFields,
|
|
21
23
|
select
|
|
22
24
|
}),
|
|
23
25
|
session: await getSession(this, req)
|
|
24
26
|
};
|
|
25
|
-
const query = await
|
|
27
|
+
const query = await buildQuery({
|
|
28
|
+
adapter: this,
|
|
29
|
+
fields: flattenedFields,
|
|
26
30
|
locale,
|
|
27
|
-
payload: this.payload,
|
|
28
31
|
where: whereToUse
|
|
29
32
|
});
|
|
30
33
|
const sanitizedData = sanitizeRelationshipIDs({
|
|
@@ -33,6 +36,9 @@ export async function updateGlobalVersion({ id, global: globalSlug, locale, opti
|
|
|
33
36
|
fields
|
|
34
37
|
});
|
|
35
38
|
const doc = await VersionModel.findOneAndUpdate(query, sanitizedData, options);
|
|
39
|
+
if (!doc) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
36
42
|
const result = JSON.parse(JSON.stringify(doc));
|
|
37
43
|
const verificationToken = doc._verificationToken;
|
|
38
44
|
// custom id type reset
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/updateGlobalVersion.ts"],"sourcesContent":["import type { QueryOptions } from 'mongoose'\n\nimport { buildVersionGlobalFields, type TypeWithID, type UpdateGlobalVersionArgs } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\n\nexport async function updateGlobalVersion<T extends TypeWithID>(\n this: MongooseAdapter,\n {\n id,\n global: globalSlug,\n locale,\n options: optionsArgs = {},\n req,\n select,\n versionData,\n where,\n }: UpdateGlobalVersionArgs<T>,\n) {\n const VersionModel = this.versions[globalSlug]\n const whereToUse = where || { id: { equals: id } }\n\n const currentGlobal = this.payload.config.globals.find((global) => global.slug === globalSlug)\n const fields = buildVersionGlobalFields(this.payload.config, currentGlobal)\n\n const options: QueryOptions = {\n ...optionsArgs,\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields:
|
|
1
|
+
{"version":3,"sources":["../src/updateGlobalVersion.ts"],"sourcesContent":["import type { QueryOptions } from 'mongoose'\n\nimport { buildVersionGlobalFields, type TypeWithID, type UpdateGlobalVersionArgs } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\n\nexport async function updateGlobalVersion<T extends TypeWithID>(\n this: MongooseAdapter,\n {\n id,\n global: globalSlug,\n locale,\n options: optionsArgs = {},\n req,\n select,\n versionData,\n where,\n }: UpdateGlobalVersionArgs<T>,\n) {\n const VersionModel = this.versions[globalSlug]\n const whereToUse = where || { id: { equals: id } }\n\n const currentGlobal = this.payload.config.globals.find((global) => global.slug === globalSlug)\n const fields = buildVersionGlobalFields(this.payload.config, currentGlobal)\n const flattenedFields = buildVersionGlobalFields(this.payload.config, currentGlobal, true)\n const options: QueryOptions = {\n ...optionsArgs,\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: flattenedFields,\n select,\n }),\n session: await getSession(this, req),\n }\n\n const query = await buildQuery({\n adapter: this,\n fields: flattenedFields,\n locale,\n where: whereToUse,\n })\n\n const sanitizedData = sanitizeRelationshipIDs({\n config: this.payload.config,\n data: versionData,\n fields,\n })\n\n const doc = await VersionModel.findOneAndUpdate(query, sanitizedData, options)\n\n if (!doc) {\n return null\n }\n\n const result = JSON.parse(JSON.stringify(doc))\n\n const verificationToken = doc._verificationToken\n\n // custom id type reset\n result.id = result._id\n if (verificationToken) {\n result._verificationToken = verificationToken\n }\n return result\n}\n"],"names":["buildVersionGlobalFields","buildQuery","buildProjectionFromSelect","getSession","sanitizeRelationshipIDs","updateGlobalVersion","id","global","globalSlug","locale","options","optionsArgs","req","select","versionData","where","VersionModel","versions","whereToUse","equals","currentGlobal","payload","config","globals","find","slug","fields","flattenedFields","lean","new","projection","adapter","session","query","sanitizedData","data","doc","findOneAndUpdate","result","JSON","parse","stringify","verificationToken","_verificationToken","_id"],"mappings":"AAEA,SAASA,wBAAwB,QAAuD,UAAS;AAIjG,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,uBAAuB,QAAQ,yCAAwC;AAEhF,OAAO,eAAeC,oBAEpB,EACEC,EAAE,EACFC,QAAQC,UAAU,EAClBC,MAAM,EACNC,SAASC,cAAc,CAAC,CAAC,EACzBC,GAAG,EACHC,MAAM,EACNC,WAAW,EACXC,KAAK,EACsB;IAE7B,MAAMC,eAAe,IAAI,CAACC,QAAQ,CAACT,WAAW;IAC9C,MAAMU,aAAaH,SAAS;QAAET,IAAI;YAAEa,QAAQb;QAAG;IAAE;IAEjD,MAAMc,gBAAgB,IAAI,CAACC,OAAO,CAACC,MAAM,CAACC,OAAO,CAACC,IAAI,CAAC,CAACjB,SAAWA,OAAOkB,IAAI,KAAKjB;IACnF,MAAMkB,SAAS1B,yBAAyB,IAAI,CAACqB,OAAO,CAACC,MAAM,EAAEF;IAC7D,MAAMO,kBAAkB3B,yBAAyB,IAAI,CAACqB,OAAO,CAACC,MAAM,EAAEF,eAAe;IACrF,MAAMV,UAAwB;QAC5B,GAAGC,WAAW;QACdiB,MAAM;QACNC,KAAK;QACLC,YAAY5B,0BAA0B;YACpC6B,SAAS,IAAI;YACbL,QAAQC;YACRd;QACF;QACAmB,SAAS,MAAM7B,WAAW,IAAI,EAAES;IAClC;IAEA,MAAMqB,QAAQ,MAAMhC,WAAW;QAC7B8B,SAAS,IAAI;QACbL,QAAQC;QACRlB;QACAM,OAAOG;IACT;IAEA,MAAMgB,gBAAgB9B,wBAAwB;QAC5CkB,QAAQ,IAAI,CAACD,OAAO,CAACC,MAAM;QAC3Ba,MAAMrB;QACNY;IACF;IAEA,MAAMU,MAAM,MAAMpB,aAAaqB,gBAAgB,CAACJ,OAAOC,eAAexB;IAEtE,IAAI,CAAC0B,KAAK;QACR,OAAO;IACT;IAEA,MAAME,SAASC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACL;IAEzC,MAAMM,oBAAoBN,IAAIO,kBAAkB;IAEhD,uBAAuB;IACvBL,OAAOhC,EAAE,GAAGgC,OAAOM,GAAG;IACtB,IAAIF,mBAAmB;QACrBJ,OAAOK,kBAAkB,GAAGD;IAC9B;IACA,OAAOJ;AACT"}
|
package/dist/updateOne.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateOne.d.ts","sourceRoot":"","sources":["../src/updateOne.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"updateOne.d.ts","sourceRoot":"","sources":["../src/updateOne.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAWxC,eAAO,MAAM,SAAS,EAAE,SAkDvB,CAAA"}
|
package/dist/updateOne.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { buildQuery } from './queries/buildQuery.js';
|
|
1
2
|
import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js';
|
|
2
3
|
import { getSession } from './utilities/getSession.js';
|
|
3
4
|
import { handleError } from './utilities/handleError.js';
|
|
@@ -22,9 +23,11 @@ export const updateOne = async function updateOne({ id, collection, data, locale
|
|
|
22
23
|
}),
|
|
23
24
|
session: await getSession(this, req)
|
|
24
25
|
};
|
|
25
|
-
const query = await
|
|
26
|
+
const query = await buildQuery({
|
|
27
|
+
adapter: this,
|
|
28
|
+
collectionSlug: collection,
|
|
29
|
+
fields: this.payload.collections[collection].config.flattenedFields,
|
|
26
30
|
locale,
|
|
27
|
-
payload: this.payload,
|
|
28
31
|
where
|
|
29
32
|
});
|
|
30
33
|
let result;
|
|
@@ -42,6 +45,9 @@ export const updateOne = async function updateOne({ id, collection, data, locale
|
|
|
42
45
|
req
|
|
43
46
|
});
|
|
44
47
|
}
|
|
48
|
+
if (!result) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
45
51
|
result = JSON.parse(JSON.stringify(result));
|
|
46
52
|
result.id = result._id;
|
|
47
53
|
result = sanitizeInternalFields(result);
|
package/dist/updateOne.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/updateOne.ts"],"sourcesContent":["import type { QueryOptions } from 'mongoose'\nimport type { UpdateOne } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { handleError } from './utilities/handleError.js'\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\n\nexport const updateOne: UpdateOne = async function updateOne(\n this: MongooseAdapter,\n { id, collection, data, locale, options: optionsArgs = {}, req, select, where: whereArg },\n) {\n const where = id ? { id: { equals: id } } : whereArg\n const Model = this.collections[collection]\n const fields = this.payload.collections[collection].config.fields\n const options: QueryOptions = {\n ...optionsArgs,\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: this.payload.collections[collection].config.flattenedFields,\n select,\n }),\n session: await getSession(this, req),\n }\n\n const query = await
|
|
1
|
+
{"version":3,"sources":["../src/updateOne.ts"],"sourcesContent":["import type { QueryOptions } from 'mongoose'\nimport type { UpdateOne } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { handleError } from './utilities/handleError.js'\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\n\nexport const updateOne: UpdateOne = async function updateOne(\n this: MongooseAdapter,\n { id, collection, data, locale, options: optionsArgs = {}, req, select, where: whereArg },\n) {\n const where = id ? { id: { equals: id } } : whereArg\n const Model = this.collections[collection]\n const fields = this.payload.collections[collection].config.fields\n const options: QueryOptions = {\n ...optionsArgs,\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: this.payload.collections[collection].config.flattenedFields,\n select,\n }),\n session: await getSession(this, req),\n }\n\n const query = await buildQuery({\n adapter: this,\n collectionSlug: collection,\n fields: this.payload.collections[collection].config.flattenedFields,\n locale,\n where,\n })\n\n let result\n\n const sanitizedData = sanitizeRelationshipIDs({\n config: this.payload.config,\n data,\n fields,\n })\n\n try {\n result = await Model.findOneAndUpdate(query, sanitizedData, options)\n } catch (error) {\n handleError({ collection, error, req })\n }\n\n if (!result) {\n return null\n }\n\n result = JSON.parse(JSON.stringify(result))\n result.id = result._id\n result = sanitizeInternalFields(result)\n\n return result\n}\n"],"names":["buildQuery","buildProjectionFromSelect","getSession","handleError","sanitizeInternalFields","sanitizeRelationshipIDs","updateOne","id","collection","data","locale","options","optionsArgs","req","select","where","whereArg","equals","Model","collections","fields","payload","config","lean","new","projection","adapter","flattenedFields","session","query","collectionSlug","result","sanitizedData","findOneAndUpdate","error","JSON","parse","stringify","_id"],"mappings":"AAKA,SAASA,UAAU,QAAQ,0BAAyB;AACpD,SAASC,yBAAyB,QAAQ,2CAA0C;AAC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AAQ;QACX,OAAO;IACT;IAEAA,SAASI,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACN;IACnCA,OAAOxB,EAAE,GAAGwB,OAAOO,GAAG;IACtBP,SAAS3B,uBAAuB2B;IAEhC,OAAOA;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateVersion.d.ts","sourceRoot":"","sources":["../src/updateVersion.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgC,KAAK,aAAa,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"updateVersion.d.ts","sourceRoot":"","sources":["../src/updateVersion.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgC,KAAK,aAAa,EAAE,MAAM,SAAS,CAAA;AAS1E,eAAO,MAAM,aAAa,EAAE,aA0D3B,CAAA"}
|
package/dist/updateVersion.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { buildVersionCollectionFields } from 'payload';
|
|
2
|
+
import { buildQuery } from './queries/buildQuery.js';
|
|
2
3
|
import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js';
|
|
3
4
|
import { getSession } from './utilities/getSession.js';
|
|
4
5
|
import { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js';
|
|
@@ -10,20 +11,22 @@ export const updateVersion = async function updateVersion({ id, collection, loca
|
|
|
10
11
|
}
|
|
11
12
|
};
|
|
12
13
|
const fields = buildVersionCollectionFields(this.payload.config, this.payload.collections[collection].config);
|
|
14
|
+
const flattenedFields = buildVersionCollectionFields(this.payload.config, this.payload.collections[collection].config, true);
|
|
13
15
|
const options = {
|
|
14
16
|
...optionsArgs,
|
|
15
17
|
lean: true,
|
|
16
18
|
new: true,
|
|
17
19
|
projection: buildProjectionFromSelect({
|
|
18
20
|
adapter: this,
|
|
19
|
-
fields:
|
|
21
|
+
fields: flattenedFields,
|
|
20
22
|
select
|
|
21
23
|
}),
|
|
22
24
|
session: await getSession(this, req)
|
|
23
25
|
};
|
|
24
|
-
const query = await
|
|
26
|
+
const query = await buildQuery({
|
|
27
|
+
adapter: this,
|
|
28
|
+
fields: flattenedFields,
|
|
25
29
|
locale,
|
|
26
|
-
payload: this.payload,
|
|
27
30
|
where: whereToUse
|
|
28
31
|
});
|
|
29
32
|
const sanitizedData = sanitizeRelationshipIDs({
|
|
@@ -32,6 +35,9 @@ export const updateVersion = async function updateVersion({ id, collection, loca
|
|
|
32
35
|
fields
|
|
33
36
|
});
|
|
34
37
|
const doc = await VersionModel.findOneAndUpdate(query, sanitizedData, options);
|
|
38
|
+
if (!doc) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
35
41
|
const result = JSON.parse(JSON.stringify(doc));
|
|
36
42
|
const verificationToken = doc._verificationToken;
|
|
37
43
|
// custom id type reset
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/updateVersion.ts"],"sourcesContent":["import type { QueryOptions } from 'mongoose'\n\nimport { buildVersionCollectionFields, type UpdateVersion } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\n\nexport const updateVersion: UpdateVersion = async function updateVersion(\n this: MongooseAdapter,\n { id, collection, locale, options: optionsArgs = {}, req, select, versionData, where },\n) {\n const VersionModel = this.versions[collection]\n const whereToUse = where || { id: { equals: id } }\n const fields = buildVersionCollectionFields(\n this.payload.config,\n this.payload.collections[collection].config,\n )\n\n const options: QueryOptions = {\n ...optionsArgs,\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields:
|
|
1
|
+
{"version":3,"sources":["../src/updateVersion.ts"],"sourcesContent":["import type { QueryOptions } from 'mongoose'\n\nimport { buildVersionCollectionFields, type UpdateVersion } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\n\nexport const updateVersion: UpdateVersion = async function updateVersion(\n this: MongooseAdapter,\n { id, collection, locale, options: optionsArgs = {}, req, select, versionData, where },\n) {\n const VersionModel = this.versions[collection]\n const whereToUse = where || { id: { equals: id } }\n const fields = buildVersionCollectionFields(\n this.payload.config,\n this.payload.collections[collection].config,\n )\n\n const flattenedFields = buildVersionCollectionFields(\n this.payload.config,\n this.payload.collections[collection].config,\n true,\n )\n\n const options: QueryOptions = {\n ...optionsArgs,\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: flattenedFields,\n select,\n }),\n session: await getSession(this, req),\n }\n\n const query = await buildQuery({\n adapter: this,\n fields: flattenedFields,\n locale,\n where: whereToUse,\n })\n\n const sanitizedData = sanitizeRelationshipIDs({\n config: this.payload.config,\n data: versionData,\n fields,\n })\n\n const doc = await VersionModel.findOneAndUpdate(query, sanitizedData, options)\n\n if (!doc) {\n return null\n }\n\n const result = JSON.parse(JSON.stringify(doc))\n\n const verificationToken = doc._verificationToken\n\n // custom id type reset\n result.id = result._id\n if (verificationToken) {\n result._verificationToken = verificationToken\n }\n return result\n}\n"],"names":["buildVersionCollectionFields","buildQuery","buildProjectionFromSelect","getSession","sanitizeRelationshipIDs","updateVersion","id","collection","locale","options","optionsArgs","req","select","versionData","where","VersionModel","versions","whereToUse","equals","fields","payload","config","collections","flattenedFields","lean","new","projection","adapter","session","query","sanitizedData","data","doc","findOneAndUpdate","result","JSON","parse","stringify","verificationToken","_verificationToken","_id"],"mappings":"AAEA,SAASA,4BAA4B,QAA4B,UAAS;AAI1E,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,uBAAuB,QAAQ,yCAAwC;AAEhF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;IAC9B;IACA,OAAOJ;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildJoinAggregation.d.ts","sourceRoot":"","sources":["../../src/utilities/buildJoinAggregation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"buildJoinAggregation.d.ts","sourceRoot":"","sources":["../../src/utilities/buildJoinAggregation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EACV,cAAc,EAEd,SAAS,EACT,yBAAyB,EACzB,KAAK,EACN,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAKlD,KAAK,wBAAwB,GAAG;IAC9B,OAAO,EAAE,eAAe,CAAA;IACxB,UAAU,EAAE,cAAc,CAAA;IAC1B,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,KAAK,EAAE,SAAS,CAAA;IAEhB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAEjC,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,oBAAoB,kGAU9B,wBAAwB,KAAG,OAAO,CAAC,aAAa,EAAE,GAAG,SAAS,CAkVhE,CAAA"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { fieldShouldBeLocalized } from 'payload/shared';
|
|
2
|
+
import { buildQuery } from '../queries/buildQuery.js';
|
|
2
3
|
import { buildSortParam } from '../queries/buildSortParam.js';
|
|
3
4
|
export const buildJoinAggregation = async ({ adapter, collection, collectionConfig, joins, limit, locale, projection, query, versions })=>{
|
|
4
|
-
if (Object.keys(collectionConfig.joins).length === 0 || joins === false) {
|
|
5
|
+
if (Object.keys(collectionConfig.joins).length === 0 && collectionConfig.polymorphicJoins.length == 0 || joins === false) {
|
|
5
6
|
return;
|
|
6
7
|
}
|
|
7
8
|
const joinConfig = adapter.payload.collections[collection].config.joins;
|
|
9
|
+
const polymorphicJoinsConfig = adapter.payload.collections[collection].config.polymorphicJoins;
|
|
8
10
|
const aggregate = [
|
|
9
11
|
{
|
|
10
12
|
$sort: {
|
|
@@ -22,21 +24,160 @@ export const buildJoinAggregation = async ({ adapter, collection, collectionConf
|
|
|
22
24
|
$limit: limit
|
|
23
25
|
});
|
|
24
26
|
}
|
|
27
|
+
for (const join of polymorphicJoinsConfig){
|
|
28
|
+
if (projection && !projection[join.joinPath]) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (joins?.[join.joinPath] === false) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const { limit: limitJoin = join.field.defaultLimit ?? 10, page, sort: sortJoin = join.field.defaultSort || collectionConfig.defaultSort, where: whereJoin } = joins?.[join.joinPath] || {};
|
|
35
|
+
const aggregatedFields = [];
|
|
36
|
+
for (const collectionSlug of join.field.collection){
|
|
37
|
+
for (const field of adapter.payload.collections[collectionSlug].config.flattenedFields){
|
|
38
|
+
if (!aggregatedFields.some((eachField)=>eachField.name === field.name)) {
|
|
39
|
+
aggregatedFields.push(field);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const sort = buildSortParam({
|
|
44
|
+
config: adapter.payload.config,
|
|
45
|
+
fields: aggregatedFields,
|
|
46
|
+
locale,
|
|
47
|
+
sort: sortJoin,
|
|
48
|
+
timestamps: true
|
|
49
|
+
});
|
|
50
|
+
const $match = await buildQuery({
|
|
51
|
+
adapter,
|
|
52
|
+
fields: aggregatedFields,
|
|
53
|
+
locale,
|
|
54
|
+
where: whereJoin
|
|
55
|
+
});
|
|
56
|
+
const sortProperty = Object.keys(sort)[0];
|
|
57
|
+
const sortDirection = sort[sortProperty] === 'asc' ? 1 : -1;
|
|
58
|
+
const projectSort = sortProperty !== '_id' && sortProperty !== 'relationTo';
|
|
59
|
+
const aliases = [];
|
|
60
|
+
const as = join.joinPath;
|
|
61
|
+
for (const collectionSlug of join.field.collection){
|
|
62
|
+
const alias = `${as}.docs.${collectionSlug}`;
|
|
63
|
+
aliases.push(alias);
|
|
64
|
+
aggregate.push({
|
|
65
|
+
$lookup: {
|
|
66
|
+
as: alias,
|
|
67
|
+
from: adapter.collections[collectionSlug].collection.name,
|
|
68
|
+
let: {
|
|
69
|
+
root_id_: '$_id'
|
|
70
|
+
},
|
|
71
|
+
pipeline: [
|
|
72
|
+
{
|
|
73
|
+
$addFields: {
|
|
74
|
+
relationTo: {
|
|
75
|
+
$literal: collectionSlug
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
$match: {
|
|
81
|
+
$and: [
|
|
82
|
+
{
|
|
83
|
+
$expr: {
|
|
84
|
+
$eq: [
|
|
85
|
+
`$${join.field.on}`,
|
|
86
|
+
'$$root_id_'
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
$match
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
$sort: {
|
|
96
|
+
[sortProperty]: sortDirection
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
// Unfortunately, we can't use $skip here because we can lose data, instead we do $slice then
|
|
101
|
+
$limit: page ? page * limitJoin : limitJoin
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
$project: {
|
|
105
|
+
value: '$_id',
|
|
106
|
+
...projectSort && {
|
|
107
|
+
[sortProperty]: 1
|
|
108
|
+
},
|
|
109
|
+
relationTo: 1
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
aggregate.push({
|
|
117
|
+
$addFields: {
|
|
118
|
+
[`${as}.docs`]: {
|
|
119
|
+
$concatArrays: aliases.map((alias)=>`$${alias}`)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
aggregate.push({
|
|
124
|
+
$set: {
|
|
125
|
+
[`${as}.docs`]: {
|
|
126
|
+
$sortArray: {
|
|
127
|
+
input: `$${as}.docs`,
|
|
128
|
+
sortBy: {
|
|
129
|
+
[sortProperty]: sortDirection
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
const sliceValue = page ? [
|
|
136
|
+
(page - 1) * limitJoin,
|
|
137
|
+
limitJoin
|
|
138
|
+
] : [
|
|
139
|
+
limitJoin
|
|
140
|
+
];
|
|
141
|
+
aggregate.push({
|
|
142
|
+
$set: {
|
|
143
|
+
[`${as}.docs`]: {
|
|
144
|
+
$slice: [
|
|
145
|
+
`$${as}.docs`,
|
|
146
|
+
...sliceValue
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
aggregate.push({
|
|
152
|
+
$addFields: {
|
|
153
|
+
[`${as}.hasNextPage`]: {
|
|
154
|
+
$gt: [
|
|
155
|
+
{
|
|
156
|
+
$size: `$${as}.docs`
|
|
157
|
+
},
|
|
158
|
+
limitJoin || Number.MAX_VALUE
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
25
164
|
for (const slug of Object.keys(joinConfig)){
|
|
26
165
|
for (const join of joinConfig[slug]){
|
|
27
|
-
const joinModel = adapter.collections[join.field.collection];
|
|
28
166
|
if (projection && !projection[join.joinPath]) {
|
|
29
167
|
continue;
|
|
30
168
|
}
|
|
31
169
|
if (joins?.[join.joinPath] === false) {
|
|
32
170
|
continue;
|
|
33
171
|
}
|
|
34
|
-
const { limit: limitJoin = join.field.defaultLimit ?? 10, sort: sortJoin = join.field.defaultSort || collectionConfig.defaultSort, where: whereJoin } = joins?.[join.joinPath] || {};
|
|
172
|
+
const { limit: limitJoin = join.field.defaultLimit ?? 10, page, sort: sortJoin = join.field.defaultSort || collectionConfig.defaultSort, where: whereJoin } = joins?.[join.joinPath] || {};
|
|
173
|
+
if (Array.isArray(join.field.collection)) {
|
|
174
|
+
throw new Error('Unreachable');
|
|
175
|
+
}
|
|
176
|
+
const joinModel = adapter.collections[join.field.collection];
|
|
35
177
|
const sort = buildSortParam({
|
|
36
178
|
config: adapter.payload.config,
|
|
37
179
|
fields: adapter.payload.collections[slug].config.flattenedFields,
|
|
38
180
|
locale,
|
|
39
|
-
parentIsLocalized: false,
|
|
40
181
|
sort: sortJoin,
|
|
41
182
|
timestamps: true
|
|
42
183
|
});
|
|
@@ -57,6 +198,11 @@ export const buildJoinAggregation = async ({ adapter, collection, collectionConf
|
|
|
57
198
|
}
|
|
58
199
|
}
|
|
59
200
|
];
|
|
201
|
+
if (page) {
|
|
202
|
+
pipeline.push({
|
|
203
|
+
$skip: (page - 1) * limitJoin
|
|
204
|
+
});
|
|
205
|
+
}
|
|
60
206
|
if (limitJoin > 0) {
|
|
61
207
|
pipeline.push({
|
|
62
208
|
$limit: limitJoin + 1
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/buildJoinAggregation.ts"],"sourcesContent":["import type { PipelineStage } from 'mongoose'\nimport type { CollectionSlug, JoinQuery, SanitizedCollectionConfig, Where } from 'payload'\n\nimport { fieldShouldBeLocalized } from 'payload/shared'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { buildSortParam } from '../queries/buildSortParam.js'\n\ntype BuildJoinAggregationArgs = {\n adapter: MongooseAdapter\n collection: CollectionSlug\n collectionConfig: SanitizedCollectionConfig\n joins: JoinQuery\n // the number of docs to get at the top collection level\n limit?: number\n locale: string\n projection?: Record<string, true>\n // the where clause for the top collection\n query?: Where\n /** whether the query is from drafts */\n versions?: boolean\n}\n\nexport const buildJoinAggregation = async ({\n adapter,\n collection,\n collectionConfig,\n joins,\n limit,\n locale,\n projection,\n query,\n versions,\n}: BuildJoinAggregationArgs): Promise<PipelineStage[] | undefined> => {\n if (Object.keys(collectionConfig.joins).length === 0 || joins === false) {\n return\n }\n\n const joinConfig = adapter.payload.collections[collection].config.joins\n const aggregate: PipelineStage[] = [\n {\n $sort: { createdAt: -1 },\n },\n ]\n\n if (query) {\n aggregate.push({\n $match: query,\n })\n }\n\n if (limit) {\n aggregate.push({\n $limit: limit,\n })\n }\n\n for (const slug of Object.keys(joinConfig)) {\n for (const join of joinConfig[slug]) {\n const joinModel = adapter.collections[join.field.collection]\n\n if (projection && !projection[join.joinPath]) {\n continue\n }\n\n if (joins?.[join.joinPath] === false) {\n continue\n }\n\n const {\n limit: limitJoin = join.field.defaultLimit ?? 10,\n sort: sortJoin = join.field.defaultSort || collectionConfig.defaultSort,\n where: whereJoin,\n } = joins?.[join.joinPath] || {}\n\n const sort = buildSortParam({\n config: adapter.payload.config,\n fields: adapter.payload.collections[slug].config.flattenedFields,\n locale,\n parentIsLocalized: false,\n sort: sortJoin,\n timestamps: true,\n })\n const sortProperty = Object.keys(sort)[0]\n const sortDirection = sort[sortProperty] === 'asc' ? 1 : -1\n\n const $match = await joinModel.buildQuery({\n locale,\n payload: adapter.payload,\n where: whereJoin,\n })\n\n const pipeline: Exclude<PipelineStage, PipelineStage.Merge | PipelineStage.Out>[] = [\n { $match },\n {\n $sort: { [sortProperty]: sortDirection },\n },\n ]\n\n if (limitJoin > 0) {\n pipeline.push({\n $limit: limitJoin + 1,\n })\n }\n\n let polymorphicSuffix = ''\n if (Array.isArray(join.targetField.relationTo)) {\n polymorphicSuffix = '.value'\n }\n\n if (adapter.payload.config.localization && locale === 'all') {\n adapter.payload.config.localization.localeCodes.forEach((code) => {\n const as = `${versions ? `version.${join.joinPath}` : join.joinPath}${code}`\n\n aggregate.push(\n {\n $lookup: {\n as: `${as}.docs`,\n foreignField: `${join.field.on}${code}${polymorphicSuffix}`,\n from: adapter.collections[slug].collection.name,\n localField: versions ? 'parent' : '_id',\n pipeline,\n },\n },\n {\n $addFields: {\n [`${as}.docs`]: {\n $map: {\n as: 'doc',\n in: '$$doc._id',\n input: `$${as}.docs`,\n },\n }, // Slicing the docs to match the limit\n [`${as}.hasNextPage`]: limitJoin\n ? { $gt: [{ $size: `$${as}.docs` }, limitJoin] }\n : false,\n // Boolean indicating if more docs than limit\n },\n },\n )\n if (limitJoin > 0) {\n aggregate.push({\n $addFields: {\n [`${as}.docs`]: {\n $slice: [`$${as}.docs`, limitJoin],\n },\n },\n })\n }\n })\n } else {\n const localeSuffix =\n fieldShouldBeLocalized({\n field: join.field,\n parentIsLocalized: join.parentIsLocalized,\n }) &&\n adapter.payload.config.localization &&\n locale\n ? `.${locale}`\n : ''\n const as = `${versions ? `version.${join.joinPath}` : join.joinPath}${localeSuffix}`\n\n let foreignField: string\n\n if (join.getForeignPath) {\n foreignField = `${join.getForeignPath({ locale })}${polymorphicSuffix}`\n } else {\n foreignField = `${join.field.on}${polymorphicSuffix}`\n }\n\n aggregate.push(\n {\n $lookup: {\n as: `${as}.docs`,\n foreignField,\n from: adapter.collections[slug].collection.name,\n localField: versions ? 'parent' : '_id',\n pipeline,\n },\n },\n {\n $addFields: {\n [`${as}.docs`]: {\n $map: {\n as: 'doc',\n in: '$$doc._id',\n input: `$${as}.docs`,\n },\n }, // Slicing the docs to match the limit\n [`${as}.hasNextPage`]: {\n $gt: [{ $size: `$${as}.docs` }, limitJoin || Number.MAX_VALUE],\n }, // Boolean indicating if more docs than limit\n },\n },\n )\n if (limitJoin > 0) {\n aggregate.push({\n $addFields: {\n [`${as}.docs`]: {\n $slice: [`$${as}.docs`, limitJoin],\n },\n },\n })\n }\n }\n }\n }\n\n if (projection) {\n aggregate.push({ $project: projection })\n }\n\n return aggregate\n}\n"],"names":["fieldShouldBeLocalized","buildSortParam","buildJoinAggregation","adapter","collection","collectionConfig","joins","limit","locale","projection","query","versions","Object","keys","length","joinConfig","payload","collections","config","aggregate","$sort","createdAt","push","$match","$limit","slug","join","joinModel","field","joinPath","limitJoin","defaultLimit","sort","sortJoin","defaultSort","where","whereJoin","fields","flattenedFields","parentIsLocalized","timestamps","sortProperty","sortDirection","buildQuery","pipeline","polymorphicSuffix","Array","isArray","targetField","relationTo","localization","localeCodes","forEach","code","as","$lookup","foreignField","on","from","name","localField","$addFields","$map","in","input","$gt","$size","$slice","localeSuffix","getForeignPath","Number","MAX_VALUE","$project"],"mappings":"AAGA,SAASA,sBAAsB,QAAQ,iBAAgB;AAIvD,SAASC,cAAc,QAAQ,+BAA8B;AAiB7D,OAAO,MAAMC,uBAAuB,OAAO,EACzCC,OAAO,EACPC,UAAU,EACVC,gBAAgB,EAChBC,KAAK,EACLC,KAAK,EACLC,MAAM,EACNC,UAAU,EACVC,KAAK,EACLC,QAAQ,EACiB;IACzB,IAAIC,OAAOC,IAAI,CAACR,iBAAiBC,KAAK,EAAEQ,MAAM,KAAK,KAAKR,UAAU,OAAO;QACvE;IACF;IAEA,MAAMS,aAAaZ,QAAQa,OAAO,CAACC,WAAW,CAACb,WAAW,CAACc,MAAM,CAACZ,KAAK;IACvE,MAAMa,YAA6B;QACjC;YACEC,OAAO;gBAAEC,WAAW,CAAC;YAAE;QACzB;KACD;IAED,IAAIX,OAAO;QACTS,UAAUG,IAAI,CAAC;YACbC,QAAQb;QACV;IACF;IAEA,IAAIH,OAAO;QACTY,UAAUG,IAAI,CAAC;YACbE,QAAQjB;QACV;IACF;IAEA,KAAK,MAAMkB,QAAQb,OAAOC,IAAI,CAACE,YAAa;QAC1C,KAAK,MAAMW,QAAQX,UAAU,CAACU,KAAK,CAAE;YACnC,MAAME,YAAYxB,QAAQc,WAAW,CAACS,KAAKE,KAAK,CAACxB,UAAU,CAAC;YAE5D,IAAIK,cAAc,CAACA,UAAU,CAACiB,KAAKG,QAAQ,CAA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],"sourcesContent":["import type { PipelineStage } from 'mongoose'\nimport type {\n CollectionSlug,\n FlattenedField,\n JoinQuery,\n SanitizedCollectionConfig,\n Where,\n} from 'payload'\n\nimport { fieldShouldBeLocalized } from 'payload/shared'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { buildQuery } from '../queries/buildQuery.js'\nimport { buildSortParam } from '../queries/buildSortParam.js'\n\ntype BuildJoinAggregationArgs = {\n adapter: MongooseAdapter\n collection: CollectionSlug\n collectionConfig: SanitizedCollectionConfig\n joins: JoinQuery\n // the number of docs to get at the top collection level\n limit?: number\n locale: string\n projection?: Record<string, true>\n // the where clause for the top collection\n query?: Where\n /** whether the query is from drafts */\n versions?: boolean\n}\n\nexport const buildJoinAggregation = async ({\n adapter,\n collection,\n collectionConfig,\n joins,\n limit,\n locale,\n projection,\n query,\n versions,\n}: BuildJoinAggregationArgs): Promise<PipelineStage[] | undefined> => {\n if (\n (Object.keys(collectionConfig.joins).length === 0 &&\n collectionConfig.polymorphicJoins.length == 0) ||\n joins === false\n ) {\n return\n }\n\n const joinConfig = adapter.payload.collections[collection].config.joins\n const polymorphicJoinsConfig = adapter.payload.collections[collection].config.polymorphicJoins\n const aggregate: PipelineStage[] = [\n {\n $sort: { createdAt: -1 },\n },\n ]\n\n if (query) {\n aggregate.push({\n $match: query,\n })\n }\n\n if (limit) {\n aggregate.push({\n $limit: limit,\n })\n }\n\n for (const join of polymorphicJoinsConfig) {\n if (projection && !projection[join.joinPath]) {\n continue\n }\n\n if (joins?.[join.joinPath] === false) {\n continue\n }\n\n const {\n limit: limitJoin = join.field.defaultLimit ?? 10,\n page,\n sort: sortJoin = join.field.defaultSort || collectionConfig.defaultSort,\n where: whereJoin,\n } = joins?.[join.joinPath] || {}\n\n const aggregatedFields: FlattenedField[] = []\n for (const collectionSlug of join.field.collection) {\n for (const field of adapter.payload.collections[collectionSlug].config.flattenedFields) {\n if (!aggregatedFields.some((eachField) => eachField.name === field.name)) {\n aggregatedFields.push(field)\n }\n }\n }\n\n const sort = buildSortParam({\n config: adapter.payload.config,\n fields: aggregatedFields,\n locale,\n sort: sortJoin,\n timestamps: true,\n })\n\n const $match = await buildQuery({\n adapter,\n fields: aggregatedFields,\n locale,\n where: whereJoin,\n })\n\n const sortProperty = Object.keys(sort)[0]\n const sortDirection = sort[sortProperty] === 'asc' ? 1 : -1\n\n const projectSort = sortProperty !== '_id' && sortProperty !== 'relationTo'\n\n const aliases: string[] = []\n\n const as = join.joinPath\n\n for (const collectionSlug of join.field.collection) {\n const alias = `${as}.docs.${collectionSlug}`\n aliases.push(alias)\n\n aggregate.push({\n $lookup: {\n as: alias,\n from: adapter.collections[collectionSlug].collection.name,\n let: {\n root_id_: '$_id',\n },\n pipeline: [\n {\n $addFields: {\n relationTo: {\n $literal: collectionSlug,\n },\n },\n },\n {\n $match: {\n $and: [\n {\n $expr: {\n $eq: [`$${join.field.on}`, '$$root_id_'],\n },\n },\n $match,\n ],\n },\n },\n {\n $sort: {\n [sortProperty]: sortDirection,\n },\n },\n {\n // Unfortunately, we can't use $skip here because we can lose data, instead we do $slice then\n $limit: page ? page * limitJoin : limitJoin,\n },\n {\n $project: {\n value: '$_id',\n ...(projectSort && {\n [sortProperty]: 1,\n }),\n relationTo: 1,\n },\n },\n ],\n },\n })\n }\n\n aggregate.push({\n $addFields: {\n [`${as}.docs`]: {\n $concatArrays: aliases.map((alias) => `$${alias}`),\n },\n },\n })\n\n aggregate.push({\n $set: {\n [`${as}.docs`]: {\n $sortArray: {\n input: `$${as}.docs`,\n sortBy: {\n [sortProperty]: sortDirection,\n },\n },\n },\n },\n })\n\n const sliceValue = page ? [(page - 1) * limitJoin, limitJoin] : [limitJoin]\n\n aggregate.push({\n $set: {\n [`${as}.docs`]: {\n $slice: [`$${as}.docs`, ...sliceValue],\n },\n },\n })\n\n aggregate.push({\n $addFields: {\n [`${as}.hasNextPage`]: {\n $gt: [{ $size: `$${as}.docs` }, limitJoin || Number.MAX_VALUE],\n },\n },\n })\n }\n\n for (const slug of Object.keys(joinConfig)) {\n for (const join of joinConfig[slug]) {\n if (projection && !projection[join.joinPath]) {\n continue\n }\n\n if (joins?.[join.joinPath] === false) {\n continue\n }\n\n const {\n limit: limitJoin = join.field.defaultLimit ?? 10,\n page,\n sort: sortJoin = join.field.defaultSort || collectionConfig.defaultSort,\n where: whereJoin,\n } = joins?.[join.joinPath] || {}\n\n if (Array.isArray(join.field.collection)) {\n throw new Error('Unreachable')\n }\n\n const joinModel = adapter.collections[join.field.collection]\n\n const sort = buildSortParam({\n config: adapter.payload.config,\n fields: adapter.payload.collections[slug].config.flattenedFields,\n locale,\n sort: sortJoin,\n timestamps: true,\n })\n const sortProperty = Object.keys(sort)[0]\n const sortDirection = sort[sortProperty] === 'asc' ? 1 : -1\n\n const $match = await joinModel.buildQuery({\n locale,\n payload: adapter.payload,\n where: whereJoin,\n })\n\n const pipeline: Exclude<PipelineStage, PipelineStage.Merge | PipelineStage.Out>[] = [\n { $match },\n {\n $sort: { [sortProperty]: sortDirection },\n },\n ]\n\n if (page) {\n pipeline.push({\n $skip: (page - 1) * limitJoin,\n })\n }\n\n if (limitJoin > 0) {\n pipeline.push({\n $limit: limitJoin + 1,\n })\n }\n\n let polymorphicSuffix = ''\n if (Array.isArray(join.targetField.relationTo)) {\n polymorphicSuffix = '.value'\n }\n\n if (adapter.payload.config.localization && locale === 'all') {\n adapter.payload.config.localization.localeCodes.forEach((code) => {\n const as = `${versions ? `version.${join.joinPath}` : join.joinPath}${code}`\n\n aggregate.push(\n {\n $lookup: {\n as: `${as}.docs`,\n foreignField: `${join.field.on}${code}${polymorphicSuffix}`,\n from: adapter.collections[slug].collection.name,\n localField: versions ? 'parent' : '_id',\n pipeline,\n },\n },\n {\n $addFields: {\n [`${as}.docs`]: {\n $map: {\n as: 'doc',\n in: '$$doc._id',\n input: `$${as}.docs`,\n },\n }, // Slicing the docs to match the limit\n [`${as}.hasNextPage`]: limitJoin\n ? { $gt: [{ $size: `$${as}.docs` }, limitJoin] }\n : false,\n // Boolean indicating if more docs than limit\n },\n },\n )\n if (limitJoin > 0) {\n aggregate.push({\n $addFields: {\n [`${as}.docs`]: {\n $slice: [`$${as}.docs`, limitJoin],\n },\n },\n })\n }\n })\n } else {\n const localeSuffix =\n fieldShouldBeLocalized({\n field: join.field,\n parentIsLocalized: join.parentIsLocalized,\n }) &&\n adapter.payload.config.localization &&\n locale\n ? `.${locale}`\n : ''\n const as = `${versions ? `version.${join.joinPath}` : join.joinPath}${localeSuffix}`\n\n let foreignField: string\n\n if (join.getForeignPath) {\n foreignField = `${join.getForeignPath({ locale })}${polymorphicSuffix}`\n } else {\n foreignField = `${join.field.on}${polymorphicSuffix}`\n }\n\n aggregate.push(\n {\n $lookup: {\n as: `${as}.docs`,\n foreignField,\n from: adapter.collections[slug].collection.name,\n localField: versions ? 'parent' : '_id',\n pipeline,\n },\n },\n {\n $addFields: {\n [`${as}.docs`]: {\n $map: {\n as: 'doc',\n in: '$$doc._id',\n input: `$${as}.docs`,\n },\n }, // Slicing the docs to match the limit\n [`${as}.hasNextPage`]: {\n $gt: [{ $size: `$${as}.docs` }, limitJoin || Number.MAX_VALUE],\n }, // Boolean indicating if more docs than limit\n },\n },\n )\n if (limitJoin > 0) {\n aggregate.push({\n $addFields: {\n [`${as}.docs`]: {\n $slice: [`$${as}.docs`, limitJoin],\n },\n },\n })\n }\n }\n }\n }\n\n if (projection) {\n aggregate.push({ $project: projection })\n }\n\n return aggregate\n}\n"],"names":["fieldShouldBeLocalized","buildQuery","buildSortParam","buildJoinAggregation","adapter","collection","collectionConfig","joins","limit","locale","projection","query","versions","Object","keys","length","polymorphicJoins","joinConfig","payload","collections","config","polymorphicJoinsConfig","aggregate","$sort","createdAt","push","$match","$limit","join","joinPath","limitJoin","field","defaultLimit","page","sort","sortJoin","defaultSort","where","whereJoin","aggregatedFields","collectionSlug","flattenedFields","some","eachField","name","fields","timestamps","sortProperty","sortDirection","projectSort","aliases","as","alias","$lookup","from","let","root_id_","pipeline","$addFields","relationTo","$literal","$and","$expr","$eq","on","$project","value","$concatArrays","map","$set","$sortArray","input","sortBy","sliceValue","$slice","$gt","$size","Number","MAX_VALUE","slug","Array","isArray","Error","joinModel","$skip","polymorphicSuffix","targetField","localization","localeCodes","forEach","code","foreignField","localField","$map","in","localeSuffix","parentIsLocalized","getForeignPath"],"mappings":"AASA,SAASA,sBAAsB,QAAQ,iBAAgB;AAIvD,SAASC,UAAU,QAAQ,2BAA0B;AACrD,SAASC,cAAc,QAAQ,+BAA8B;AAiB7D,OAAO,MAAMC,uBAAuB,OAAO,EACzCC,OAAO,EACPC,UAAU,EACVC,gBAAgB,EAChBC,KAAK,EACLC,KAAK,EACLC,MAAM,EACNC,UAAU,EACVC,KAAK,EACLC,QAAQ,EACiB;IACzB,IACE,AAACC,OAAOC,IAAI,CAACR,iBAAiBC,KAAK,EAAEQ,MAAM,KAAK,KAC9CT,iBAAiBU,gBAAgB,CAACD,MAAM,IAAI,KAC9CR,UAAU,OACV;QACA;IACF;IAEA,MAAMU,aAAab,QAAQc,OAAO,CAACC,WAAW,CAACd,WAAW,CAACe,MAAM,CAACb,KAAK;IACvE,MAAMc,yBAAyBjB,QAAQc,OAAO,CAACC,WAAW,CAACd,WAAW,CAACe,MAAM,CAACJ,gBAAgB;IAC9F,MAAMM,YAA6B;QACjC;YACEC,OAAO;gBAAEC,WAAW,CAAC;YAAE;QACzB;KACD;IAED,IAAIb,OAAO;QACTW,UAAUG,IAAI,CAAC;YACbC,QAAQf;QACV;IACF;IAEA,IAAIH,OAAO;QACTc,UAAUG,IAAI,CAAC;YACbE,QAAQnB;QACV;IACF;IAEA,KAAK,MAAMoB,QAAQP,uBAAwB;QACzC,IAAIX,cAAc,CAACA,UAAU,CAACkB,KAAKC,QAAQ,CAAC,EAAE;YAC5C;QACF;QAEA,IAAItB,OAAO,CAACqB,KAAKC,QAAQ,CAAC,KAAK,OAAO;YACpC;QACF;QAEA,MAAM,EACJrB,OAAOsB,YAAYF,KAAKG,KAAK,CAACC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ACA;oBACEC,YAAY;wBACV,CAAC,GAAGP,GAAG,KAAK,CAAC,CAAC,EAAE;4BACd0C,MAAM;gCACJ1C,IAAI;gCACJ2C,IAAI;gCACJvB,OAAO,CAAC,CAAC,EAAEpB,GAAG,KAAK,CAAC;4BACtB;wBACF;wBACA,CAAC,GAAGA,GAAG,YAAY,CAAC,CAAC,EAAE;4BACrBwB,KAAK;gCAAC;oCAAEC,OAAO,CAAC,CAAC,EAAEzB,GAAG,KAAK,CAAC;gCAAC;gCAAGrB,aAAa+C,OAAOC,SAAS;6BAAC;wBAChE;oBACF;gBACF;gBAEF,IAAIhD,YAAY,GAAG;oBACjBR,UAAUG,IAAI,CAAC;wBACbiC,YAAY;4BACV,CAAC,GAAGP,GAAG,KAAK,CAAC,CAAC,EAAE;gCACduB,QAAQ;oCAAC,CAAC,CAAC,EAAEvB,GAAG,KAAK,CAAC;oCAAErB;iCAAU;4BACpC;wBACF;oBACF;gBACF;YACF;QACF;IACF;IAEA,IAAIpB,YAAY;QACdY,UAAUG,IAAI,CAAC;YAAEwC,UAAUvD;QAAW;IACxC;IAEA,OAAOY;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildProjectionFromSelect.d.ts","sourceRoot":"","sources":["../../src/utilities/buildProjectionFromSelect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,cAAc,EAAc,UAAU,EAAE,MAAM,SAAS,CAAA;AASzF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"buildProjectionFromSelect.d.ts","sourceRoot":"","sources":["../../src/utilities/buildProjectionFromSelect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,cAAc,EAAc,UAAU,EAAE,MAAM,SAAS,CAAA;AASzF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AA6KlD,eAAO,MAAM,yBAAyB,iCAInC;IACD,OAAO,EAAE,eAAe,CAAA;IACxB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,MAAM,CAAC,EAAE,UAAU,CAAA;CACpB,KAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,SAmB1B,CAAA"}
|