@payloadcms/db-mongodb 4.0.0-internal.a1317b2 → 4.0.0-internal.a2d053c
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/connect.d.ts.map +1 -1
- package/dist/connect.js +8 -2
- package/dist/connect.js.map +1 -1
- package/dist/exports/migration-utils.d.ts +1 -0
- package/dist/exports/migration-utils.d.ts.map +1 -1
- package/dist/exports/migration-utils.js +1 -0
- package/dist/exports/migration-utils.js.map +1 -1
- package/dist/findDistinct.d.ts.map +1 -1
- package/dist/findDistinct.js +52 -8
- package/dist/findDistinct.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +89 -67
- package/dist/init.js.map +1 -1
- package/dist/migrateFresh.d.ts.map +1 -1
- package/dist/migrateFresh.js +1 -0
- package/dist/migrateFresh.js.map +1 -1
- package/dist/models/buildCollectionSchema.d.ts +8 -2
- package/dist/models/buildCollectionSchema.d.ts.map +1 -1
- package/dist/models/buildCollectionSchema.js +4 -2
- package/dist/models/buildCollectionSchema.js.map +1 -1
- package/dist/models/buildGlobalModel.d.ts +5 -1
- package/dist/models/buildGlobalModel.d.ts.map +1 -1
- package/dist/models/buildGlobalModel.js +4 -2
- package/dist/models/buildGlobalModel.js.map +1 -1
- package/dist/models/buildSchema.d.ts +4 -0
- package/dist/models/buildSchema.d.ts.map +1 -1
- package/dist/models/buildSchema.js +64 -26
- package/dist/models/buildSchema.js.map +1 -1
- package/dist/models/schemaBuildContext.d.ts +21 -0
- package/dist/models/schemaBuildContext.d.ts.map +1 -0
- package/dist/models/schemaBuildContext.js +29 -0
- package/dist/models/schemaBuildContext.js.map +1 -0
- package/dist/predefinedMigrations/migrateSizesToVariants.d.ts +13 -0
- package/dist/predefinedMigrations/migrateSizesToVariants.d.ts.map +1 -0
- package/dist/predefinedMigrations/migrateSizesToVariants.js +368 -0
- package/dist/predefinedMigrations/migrateSizesToVariants.js.map +1 -0
- package/dist/predefinedMigrations/sizes-to-variants.d.ts +5 -0
- package/dist/predefinedMigrations/sizes-to-variants.d.ts.map +1 -0
- package/dist/predefinedMigrations/sizes-to-variants.js +8 -0
- package/dist/predefinedMigrations/sizes-to-variants.js.map +1 -0
- package/dist/queries/buildSearchParams.d.ts.map +1 -1
- package/dist/queries/buildSearchParams.js +50 -0
- package/dist/queries/buildSearchParams.js.map +1 -1
- package/dist/updateGlobal.js +2 -2
- package/dist/updateGlobal.js.map +1 -1
- package/dist/updateGlobalVersion.js +2 -2
- package/dist/updateGlobalVersion.js.map +1 -1
- package/dist/updateJobs.js +1 -1
- package/dist/updateJobs.js.map +1 -1
- package/dist/updateMany.d.ts.map +1 -1
- package/dist/updateMany.js +0 -1
- package/dist/updateMany.js.map +1 -1
- package/dist/updateOne.js +2 -2
- package/dist/updateOne.js.map +1 -1
- package/dist/updateVersion.js +2 -2
- package/dist/updateVersion.js.map +1 -1
- package/dist/utilities/aggregatePaginate.d.ts.map +1 -1
- package/dist/utilities/aggregatePaginate.js +3 -1
- package/dist/utilities/aggregatePaginate.js.map +1 -1
- package/dist/utilities/buildJoinAggregation.d.ts.map +1 -1
- package/dist/utilities/buildJoinAggregation.js +17 -13
- package/dist/utilities/buildJoinAggregation.js.map +1 -1
- package/package.json +16 -19
- package/dist/queries/buildSortParam.spec.js +0 -123
- package/dist/queries/buildSortParam.spec.js.map +0 -1
- package/dist/queries/getLocalizedSortProperty.spec.js +0 -215
- package/dist/queries/getLocalizedSortProperty.spec.js.map +0 -1
- package/dist/utilities/transform.spec.js +0 -546
- package/dist/utilities/transform.spec.js.map +0 -1
package/dist/connect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAa,MAAM,SAAS,CAAA;AAOjD,eAAO,MAAM,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAa,MAAM,SAAS,CAAA;AAOjD,eAAO,MAAM,OAAO,EAAE,OAkHrB,CAAA"}
|
package/dist/connect.js
CHANGED
|
@@ -64,8 +64,14 @@ export const connect = async function connect(options = {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
if (this.ensureIndexes) {
|
|
67
|
-
await Promise.all(
|
|
68
|
-
|
|
67
|
+
await Promise.all([
|
|
68
|
+
...this.payload.config.collections.flatMap((collection)=>[
|
|
69
|
+
this.collections[collection.slug],
|
|
70
|
+
this.versions[collection.slug]
|
|
71
|
+
]),
|
|
72
|
+
...this.payload.config.globals.map((global)=>this.versions[global.slug])
|
|
73
|
+
].map(async (model)=>{
|
|
74
|
+
await model?.ensureIndexes();
|
|
69
75
|
}));
|
|
70
76
|
}
|
|
71
77
|
if (process.env.NODE_ENV === 'production' && this.prodMigrations) {
|
package/dist/connect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { ConnectOptions } from 'mongoose'\nimport type { Connect, Migration } from 'payload'\n\nimport mongoose from 'mongoose'\nimport { defaultBeginTransaction } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nexport const connect: Connect = async function connect(\n this: MongooseAdapter,\n options = {\n hotReload: false,\n },\n) {\n const { hotReload } = options\n\n if (this.url === false) {\n return\n }\n\n if (typeof this.url !== 'string') {\n throw new Error('Error: missing MongoDB connection URL.')\n }\n\n const urlToConnect = this.url\n\n const connectionOptions: ConnectOptions = {\n autoIndex: true,\n ...this.connectOptions,\n }\n\n if (hotReload) {\n connectionOptions.autoIndex = false\n }\n\n try {\n if (!this.connection) {\n this.connection = await mongoose.createConnection(urlToConnect, connectionOptions).asPromise()\n if (this.afterCreateConnection) {\n await this.afterCreateConnection(this)\n }\n }\n\n await this.connection.openUri(urlToConnect, connectionOptions)\n\n if (this.afterOpenConnection) {\n await this.afterOpenConnection(this)\n }\n\n if (this.useAlternativeDropDatabase) {\n if (this.connection.db) {\n // Firestore doesn't support dropDatabase, so we monkey patch\n // dropDatabase to delete all documents from all collections instead\n this.connection.db.dropDatabase = async function (): Promise<boolean> {\n const existingCollections = await this.listCollections().toArray()\n await Promise.all(\n existingCollections.map(async (collectionInfo) => {\n const collection = this.collection(collectionInfo.name)\n await collection.deleteMany({})\n }),\n )\n return true\n }\n this.connection.dropDatabase = async function () {\n await this.db?.dropDatabase()\n }\n }\n }\n\n // If we are running a replica set with MongoDB Memory Server,\n // wait until the replica set elects a primary before proceeding\n if (this.mongoMemoryServer) {\n this.payload.logger.info(\n 'Waiting for MongoDB Memory Server replica set to elect a primary...',\n )\n await new Promise((resolve) => setTimeout(resolve, 2000))\n }\n\n if (!this.connection.getClient().options.replicaSet) {\n this.transactionOptions = false\n this.beginTransaction = defaultBeginTransaction()\n }\n\n if (!hotReload) {\n if (process.env.PAYLOAD_DROP_DATABASE === 'true') {\n this.payload.logger.info('---- DROPPING DATABASE ----')\n await this.connection.dropDatabase()\n\n this.payload.logger.info('---- DROPPED DATABASE ----')\n }\n }\n\n if (this.ensureIndexes) {\n await Promise.all(\n this.payload.config.collections.
|
|
1
|
+
{"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { ConnectOptions } from 'mongoose'\nimport type { Connect, Migration } from 'payload'\n\nimport mongoose from 'mongoose'\nimport { defaultBeginTransaction } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nexport const connect: Connect = async function connect(\n this: MongooseAdapter,\n options = {\n hotReload: false,\n },\n) {\n const { hotReload } = options\n\n if (this.url === false) {\n return\n }\n\n if (typeof this.url !== 'string') {\n throw new Error('Error: missing MongoDB connection URL.')\n }\n\n const urlToConnect = this.url\n\n const connectionOptions: ConnectOptions = {\n autoIndex: true,\n ...this.connectOptions,\n }\n\n if (hotReload) {\n connectionOptions.autoIndex = false\n }\n\n try {\n if (!this.connection) {\n this.connection = await mongoose.createConnection(urlToConnect, connectionOptions).asPromise()\n if (this.afterCreateConnection) {\n await this.afterCreateConnection(this)\n }\n }\n\n await this.connection.openUri(urlToConnect, connectionOptions)\n\n if (this.afterOpenConnection) {\n await this.afterOpenConnection(this)\n }\n\n if (this.useAlternativeDropDatabase) {\n if (this.connection.db) {\n // Firestore doesn't support dropDatabase, so we monkey patch\n // dropDatabase to delete all documents from all collections instead\n this.connection.db.dropDatabase = async function (): Promise<boolean> {\n const existingCollections = await this.listCollections().toArray()\n await Promise.all(\n existingCollections.map(async (collectionInfo) => {\n const collection = this.collection(collectionInfo.name)\n await collection.deleteMany({})\n }),\n )\n return true\n }\n this.connection.dropDatabase = async function () {\n await this.db?.dropDatabase()\n }\n }\n }\n\n // If we are running a replica set with MongoDB Memory Server,\n // wait until the replica set elects a primary before proceeding\n if (this.mongoMemoryServer) {\n this.payload.logger.info(\n 'Waiting for MongoDB Memory Server replica set to elect a primary...',\n )\n await new Promise((resolve) => setTimeout(resolve, 2000))\n }\n\n if (!this.connection.getClient().options.replicaSet) {\n this.transactionOptions = false\n this.beginTransaction = defaultBeginTransaction()\n }\n\n if (!hotReload) {\n if (process.env.PAYLOAD_DROP_DATABASE === 'true') {\n this.payload.logger.info('---- DROPPING DATABASE ----')\n await this.connection.dropDatabase()\n\n this.payload.logger.info('---- DROPPED DATABASE ----')\n }\n }\n\n if (this.ensureIndexes) {\n await Promise.all(\n [\n ...this.payload.config.collections.flatMap((collection) => [\n this.collections[collection.slug],\n this.versions[collection.slug],\n ]),\n ...this.payload.config.globals.map((global) => this.versions[global.slug]),\n ].map(async (model) => {\n await model?.ensureIndexes()\n }),\n )\n }\n\n if (process.env.NODE_ENV === 'production' && this.prodMigrations) {\n await this.migrate({ migrations: this.prodMigrations as unknown as Migration[] })\n }\n } catch (err) {\n let msg = `Error: cannot connect to MongoDB.`\n\n if (typeof err === 'object' && err && 'message' in err && typeof err.message === 'string') {\n msg = `${msg} Details: ${err.message}`\n }\n\n this.payload.logger.error({\n err,\n msg,\n })\n throw new Error(`Error: cannot connect to MongoDB: ${msg}`)\n }\n}\n"],"names":["mongoose","defaultBeginTransaction","connect","options","hotReload","url","Error","urlToConnect","connectionOptions","autoIndex","connectOptions","connection","createConnection","asPromise","afterCreateConnection","openUri","afterOpenConnection","useAlternativeDropDatabase","db","dropDatabase","existingCollections","listCollections","toArray","Promise","all","map","collectionInfo","collection","name","deleteMany","mongoMemoryServer","payload","logger","info","resolve","setTimeout","getClient","replicaSet","transactionOptions","beginTransaction","process","env","PAYLOAD_DROP_DATABASE","ensureIndexes","config","collections","flatMap","slug","versions","globals","global","model","NODE_ENV","prodMigrations","migrate","migrations","err","msg","message","error"],"mappings":"AAGA,OAAOA,cAAc,WAAU;AAC/B,SAASC,uBAAuB,QAAQ,UAAS;AAIjD,OAAO,MAAMC,UAAmB,eAAeA,QAE7CC,UAAU;IACRC,WAAW;AACb,CAAC;IAED,MAAM,EAAEA,SAAS,EAAE,GAAGD;IAEtB,IAAI,IAAI,CAACE,GAAG,KAAK,OAAO;QACtB;IACF;IAEA,IAAI,OAAO,IAAI,CAACA,GAAG,KAAK,UAAU;QAChC,MAAM,IAAIC,MAAM;IAClB;IAEA,MAAMC,eAAe,IAAI,CAACF,GAAG;IAE7B,MAAMG,oBAAoC;QACxCC,WAAW;QACX,GAAG,IAAI,CAACC,cAAc;IACxB;IAEA,IAAIN,WAAW;QACbI,kBAAkBC,SAAS,GAAG;IAChC;IAEA,IAAI;QACF,IAAI,CAAC,IAAI,CAACE,UAAU,EAAE;YACpB,IAAI,CAACA,UAAU,GAAG,MAAMX,SAASY,gBAAgB,CAACL,cAAcC,mBAAmBK,SAAS;YAC5F,IAAI,IAAI,CAACC,qBAAqB,EAAE;gBAC9B,MAAM,IAAI,CAACA,qBAAqB,CAAC,IAAI;YACvC;QACF;QAEA,MAAM,IAAI,CAACH,UAAU,CAACI,OAAO,CAACR,cAAcC;QAE5C,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AAE;YACtB,MAAMpB,QAAQC,GAAG,CACf;mBACK,IAAI,CAACO,OAAO,CAACa,MAAM,CAACC,WAAW,CAACC,OAAO,CAAC,CAACnB,aAAe;wBACzD,IAAI,CAACkB,WAAW,CAAClB,WAAWoB,IAAI,CAAC;wBACjC,IAAI,CAACC,QAAQ,CAACrB,WAAWoB,IAAI,CAAC;qBAC/B;mBACE,IAAI,CAAChB,OAAO,CAACa,MAAM,CAACK,OAAO,CAACxB,GAAG,CAAC,CAACyB,SAAW,IAAI,CAACF,QAAQ,CAACE,OAAOH,IAAI,CAAC;aAC1E,CAACtB,GAAG,CAAC,OAAO0B;gBACX,MAAMA,OAAOR;YACf;QAEJ;QAEA,IAAIH,QAAQC,GAAG,CAACW,QAAQ,KAAK,gBAAgB,IAAI,CAACC,cAAc,EAAE;YAChE,MAAM,IAAI,CAACC,OAAO,CAAC;gBAAEC,YAAY,IAAI,CAACF,cAAc;YAA2B;QACjF;IACF,EAAE,OAAOG,KAAK;QACZ,IAAIC,MAAM,CAAC,iCAAiC,CAAC;QAE7C,IAAI,OAAOD,QAAQ,YAAYA,OAAO,aAAaA,OAAO,OAAOA,IAAIE,OAAO,KAAK,UAAU;YACzFD,MAAM,GAAGA,IAAI,UAAU,EAAED,IAAIE,OAAO,EAAE;QACxC;QAEA,IAAI,CAAC3B,OAAO,CAACC,MAAM,CAAC2B,KAAK,CAAC;YACxBH;YACAC;QACF;QACA,MAAM,IAAInD,MAAM,CAAC,kCAAkC,EAAEmD,KAAK;IAC5D;AACF,EAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { localizeStatus, migrateLocalizeStatus, } from '../predefinedMigrations/migrateLocalizeStatus.js';
|
|
2
2
|
export { migrateRelationshipsV2_V3 } from '../predefinedMigrations/migrateRelationshipsV2_V3.js';
|
|
3
|
+
export { migrateSizesToVariants } from '../predefinedMigrations/migrateSizesToVariants.js';
|
|
3
4
|
export { migrateVersionsV1_V2 } from '../predefinedMigrations/migrateVersionsV1_V2.js';
|
|
4
5
|
//# sourceMappingURL=migration-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-utils.d.ts","sourceRoot":"","sources":["../../src/exports/migration-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,qBAAqB,GACtB,MAAM,kDAAkD,CAAA;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sDAAsD,CAAA;AAChG,OAAO,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAA"}
|
|
1
|
+
{"version":3,"file":"migration-utils.d.ts","sourceRoot":"","sources":["../../src/exports/migration-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,qBAAqB,GACtB,MAAM,kDAAkD,CAAA;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sDAAsD,CAAA;AAChG,OAAO,EAAE,sBAAsB,EAAE,MAAM,mDAAmD,CAAA;AAC1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { localizeStatus, migrateLocalizeStatus } from '../predefinedMigrations/migrateLocalizeStatus.js';
|
|
2
2
|
export { migrateRelationshipsV2_V3 } from '../predefinedMigrations/migrateRelationshipsV2_V3.js';
|
|
3
|
+
export { migrateSizesToVariants } from '../predefinedMigrations/migrateSizesToVariants.js';
|
|
3
4
|
export { migrateVersionsV1_V2 } from '../predefinedMigrations/migrateVersionsV1_V2.js';
|
|
4
5
|
|
|
5
6
|
//# sourceMappingURL=migration-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/migration-utils.ts"],"sourcesContent":["export {\n localizeStatus,\n migrateLocalizeStatus,\n} from '../predefinedMigrations/migrateLocalizeStatus.js'\nexport { migrateRelationshipsV2_V3 } from '../predefinedMigrations/migrateRelationshipsV2_V3.js'\nexport { migrateVersionsV1_V2 } from '../predefinedMigrations/migrateVersionsV1_V2.js'\n"],"names":["localizeStatus","migrateLocalizeStatus","migrateRelationshipsV2_V3","migrateVersionsV1_V2"],"mappings":"AAAA,SACEA,cAAc,EACdC,qBAAqB,QAChB,mDAAkD;AACzD,SAASC,yBAAyB,QAAQ,uDAAsD;AAChG,SAASC,oBAAoB,QAAQ,kDAAiD"}
|
|
1
|
+
{"version":3,"sources":["../../src/exports/migration-utils.ts"],"sourcesContent":["export {\n localizeStatus,\n migrateLocalizeStatus,\n} from '../predefinedMigrations/migrateLocalizeStatus.js'\nexport { migrateRelationshipsV2_V3 } from '../predefinedMigrations/migrateRelationshipsV2_V3.js'\nexport { migrateSizesToVariants } from '../predefinedMigrations/migrateSizesToVariants.js'\nexport { migrateVersionsV1_V2 } from '../predefinedMigrations/migrateVersionsV1_V2.js'\n"],"names":["localizeStatus","migrateLocalizeStatus","migrateRelationshipsV2_V3","migrateSizesToVariants","migrateVersionsV1_V2"],"mappings":"AAAA,SACEA,cAAc,EACdC,qBAAqB,QAChB,mDAAkD;AACzD,SAASC,yBAAyB,QAAQ,uDAAsD;AAChG,SAASC,sBAAsB,QAAQ,oDAAmD;AAC1F,SAASC,oBAAoB,QAAQ,kDAAiD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findDistinct.d.ts","sourceRoot":"","sources":["../src/findDistinct.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,SAAS,CAAA;AA6C3D,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"findDistinct.d.ts","sourceRoot":"","sources":["../src/findDistinct.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,SAAS,CAAA;AA6C3D,eAAO,MAAM,YAAY,EAAE,YA4S1B,CAAA"}
|
package/dist/findDistinct.js
CHANGED
|
@@ -114,30 +114,74 @@ export const findDistinct = async function(args) {
|
|
|
114
114
|
sortProperty = sortWithoutRelationPrefix;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
relationLookup =
|
|
117
|
+
relationLookup = [];
|
|
118
|
+
for (const { fieldPath, relationTo } of rels){
|
|
118
119
|
sortAggregation = sortAggregation.filter((each)=>{
|
|
119
120
|
if ('$lookup' in each && each.$lookup.as.replace(/^_+/, '') === fieldPath) {
|
|
120
121
|
return false;
|
|
121
122
|
}
|
|
122
123
|
return true;
|
|
123
124
|
});
|
|
124
|
-
const { Model: foreignModel } = getCollection({
|
|
125
|
+
const { collectionConfig: foreignCollectionConfig, Model: foreignModel } = getCollection({
|
|
125
126
|
adapter: this,
|
|
126
127
|
collectionSlug: relationTo
|
|
127
128
|
});
|
|
128
|
-
|
|
129
|
+
const relatedAccess = args.relatedAccess?.[fieldPath];
|
|
130
|
+
const relatedAccessQuery = relatedAccess ? await buildQuery({
|
|
131
|
+
adapter: this,
|
|
132
|
+
collectionSlug: relationTo,
|
|
133
|
+
fields: foreignCollectionConfig.flattenedFields,
|
|
134
|
+
locale: args.locale,
|
|
135
|
+
where: relatedAccess
|
|
136
|
+
}) : null;
|
|
137
|
+
relationLookup.push({
|
|
129
138
|
$lookup: {
|
|
130
139
|
as: fieldPath,
|
|
131
|
-
foreignField: '_id',
|
|
132
140
|
from: foreignModel.collection.name,
|
|
133
|
-
|
|
141
|
+
...relatedAccessQuery ? {
|
|
142
|
+
let: {
|
|
143
|
+
relatedIDs: `$${fieldPath}`
|
|
144
|
+
},
|
|
145
|
+
pipeline: [
|
|
146
|
+
{
|
|
147
|
+
$match: {
|
|
148
|
+
$and: [
|
|
149
|
+
{
|
|
150
|
+
$expr: {
|
|
151
|
+
$cond: {
|
|
152
|
+
else: {
|
|
153
|
+
$eq: [
|
|
154
|
+
'$_id',
|
|
155
|
+
'$$relatedIDs'
|
|
156
|
+
]
|
|
157
|
+
},
|
|
158
|
+
if: {
|
|
159
|
+
$isArray: '$$relatedIDs'
|
|
160
|
+
},
|
|
161
|
+
then: {
|
|
162
|
+
$in: [
|
|
163
|
+
'$_id',
|
|
164
|
+
'$$relatedIDs'
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
relatedAccessQuery
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
} : {
|
|
176
|
+
foreignField: '_id',
|
|
177
|
+
localField: fieldPath
|
|
178
|
+
}
|
|
134
179
|
}
|
|
135
180
|
});
|
|
136
|
-
|
|
181
|
+
relationLookup.push({
|
|
137
182
|
$unwind: `$${fieldPath}`
|
|
138
183
|
});
|
|
139
|
-
|
|
140
|
-
}, []);
|
|
184
|
+
}
|
|
141
185
|
}
|
|
142
186
|
let $unwind = '';
|
|
143
187
|
let $group = null;
|
package/dist/findDistinct.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/findDistinct.ts"],"sourcesContent":["import type { PipelineStage } from 'mongoose'\nimport type { FindDistinct, FlattenedField } from 'payload'\n\nimport { getFieldByPath } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\n\nconst sanitizeGroupID = (id: any) => {\n if (id && typeof id === 'object' && '_field' in id) {\n return id._field\n }\n\n return id\n}\n\nconst getSortAggregation = ({\n fieldPath,\n hasSortAggregationAndHasMany,\n sortDirection,\n sortProperty,\n}: {\n fieldPath: string\n hasSortAggregationAndHasMany: boolean\n sortDirection: -1 | 1\n sortProperty: string\n}): Record<string, -1 | 1> => {\n let resolvedSortProperty: string\n\n if (hasSortAggregationAndHasMany) {\n if (sortProperty === fieldPath) {\n resolvedSortProperty = `_id._field`\n } else {\n resolvedSortProperty = `_id._sort`\n }\n } else {\n resolvedSortProperty = sortProperty === fieldPath ? '_id' : '_sort'\n }\n\n return { [`${resolvedSortProperty}`]: sortDirection }\n}\n\nexport const findDistinct: FindDistinct = async function (this: MongooseAdapter, args) {\n const { collectionConfig, Model } = getCollection({\n adapter: this,\n collectionSlug: args.collection,\n })\n\n const { where = {} } = args\n\n let sortAggregation: PipelineStage[] = []\n\n const sort = buildSortParam({\n adapter: this,\n config: this.payload.config,\n fields: collectionConfig.flattenedFields,\n locale: args.locale,\n sort: args.sort ?? args.field,\n sortAggregation,\n timestamps: true,\n })\n\n const query = await buildQuery({\n adapter: this,\n collectionSlug: args.collection,\n fields: collectionConfig.flattenedFields,\n locale: args.locale,\n where,\n })\n\n const fieldPathResult = getFieldByPath({\n config: this.payload.config,\n fields: collectionConfig.flattenedFields,\n includeRelationships: true,\n path: args.field,\n })\n let fieldPath = args.field\n if (fieldPathResult?.pathHasLocalized && args.locale) {\n fieldPath = fieldPathResult.localizedPath.replace('<locale>', args.locale)\n }\n\n const page = args.page || 1\n\n let sortProperty = Object.keys(sort)[0]! // assert because buildSortParam always returns at least 1 key.\n const sortDirection = sort[sortProperty] === 'asc' ? 1 : -1\n\n let currentFields = collectionConfig.flattenedFields\n let foundField: FlattenedField | null = null\n\n let rels: {\n fieldPath: string\n relationTo: string\n }[] = []\n\n let tempPath = ''\n let insideRelation = false\n\n const segments = args.field.split('.')\n\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i]\n const field = currentFields.find((e) => e.name === segment)\n if (rels.length) {\n insideRelation = true\n }\n\n if (!field) {\n break\n }\n\n if (tempPath) {\n tempPath = `${tempPath}.${field.name}`\n } else {\n tempPath = field.name\n }\n\n if ('flattenedFields' in field) {\n currentFields = field.flattenedFields\n continue\n }\n\n if (\n (field.type === 'relationship' || field.type === 'upload') &&\n typeof field.relationTo === 'string'\n ) {\n if (i === segments.length - 2 && segments[i + 1] === 'id') {\n foundField = field\n fieldPath = tempPath\n break\n }\n rels.push({ fieldPath: tempPath, relationTo: field.relationTo })\n currentFields = this.payload.collections[field.relationTo]?.config\n .flattenedFields as FlattenedField[]\n continue\n }\n foundField = field\n }\n\n const resolvedField = foundField || fieldPathResult?.field\n const isHasManyValue = resolvedField && 'hasMany' in resolvedField && resolvedField\n\n let relationLookup: null | PipelineStage[] = null\n\n if (!insideRelation) {\n rels = []\n }\n\n if (rels.length) {\n if (sortProperty.startsWith('_')) {\n const sortWithoutRelationPrefix = sortProperty.replace(/^_+/, '')\n const lastFieldPath = rels.at(-1)?.fieldPath as string\n if (sortWithoutRelationPrefix.startsWith(lastFieldPath)) {\n sortProperty = sortWithoutRelationPrefix\n }\n }\n relationLookup = rels.reduce<PipelineStage[]>((acc, { fieldPath, relationTo }) => {\n sortAggregation = sortAggregation.filter((each) => {\n if ('$lookup' in each && each.$lookup.as.replace(/^_+/, '') === fieldPath) {\n return false\n }\n\n return true\n })\n const { Model: foreignModel } = getCollection({ adapter: this, collectionSlug: relationTo })\n acc.push({\n $lookup: {\n as: fieldPath,\n foreignField: '_id',\n from: foreignModel.collection.name,\n localField: fieldPath,\n },\n })\n acc.push({ $unwind: `$${fieldPath}` })\n return acc\n }, [])\n }\n\n let $unwind: any = ''\n let $group: any = null\n if (\n isHasManyValue &&\n sortAggregation.length &&\n sortAggregation[0] &&\n '$lookup' in sortAggregation[0]\n ) {\n $unwind = { path: `$${sortAggregation[0].$lookup.as}`, preserveNullAndEmptyArrays: true }\n $group = {\n _id: {\n _field: `$${sortAggregation[0].$lookup.as}._id`,\n _sort: `$${sortProperty}`,\n },\n }\n } else if (isHasManyValue) {\n $unwind = { path: `$${args.field}`, preserveNullAndEmptyArrays: true }\n }\n\n if (!$group) {\n $group = {\n _id: `$${fieldPath}`,\n ...(sortProperty === fieldPath\n ? {}\n : {\n _sort: { $max: `$${sortProperty}` },\n }),\n }\n }\n\n const pipeline: PipelineStage[] = [\n {\n $match: query,\n },\n ...(sortAggregation.length > 0 ? sortAggregation : []),\n ...(relationLookup?.length ? relationLookup : []),\n ...($unwind\n ? [\n {\n $unwind,\n },\n ]\n : []),\n {\n $group,\n },\n {\n $sort: getSortAggregation({\n fieldPath,\n hasSortAggregationAndHasMany: Boolean(isHasManyValue) && Boolean(sortAggregation.length),\n sortDirection,\n sortProperty,\n }),\n },\n ]\n\n const session = await getSession(this, args.req)\n\n const getValues = async () => {\n return Model.aggregate(pipeline, { session }).then((res) =>\n res.map((each) => ({\n [args.field]: JSON.parse(JSON.stringify(sanitizeGroupID(each._id))),\n })),\n )\n }\n\n if (args.limit) {\n pipeline.push({\n $skip: (page - 1) * args.limit,\n })\n pipeline.push({ $limit: args.limit })\n\n // Build count pipeline with the same structure as the main pipeline\n // to ensure relationship lookups are included\n const countPipeline: PipelineStage[] = [\n {\n $match: query,\n },\n ...(sortAggregation.length > 0 ? sortAggregation : []),\n ...(relationLookup?.length ? relationLookup : []),\n ...($unwind\n ? [\n {\n $unwind,\n },\n ]\n : []),\n {\n $group,\n },\n { $count: 'count' },\n ]\n\n const totalDocs = await Model.aggregate(countPipeline, {\n session,\n }).then((res) => res[0]?.count ?? 0)\n const totalPages = Math.ceil(totalDocs / args.limit)\n const hasPrevPage = page > 1\n const hasNextPage = totalPages > page\n const pagingCounter = (page - 1) * args.limit + 1\n\n return {\n hasNextPage,\n hasPrevPage,\n limit: args.limit,\n nextPage: hasNextPage ? page + 1 : null,\n page,\n pagingCounter,\n prevPage: hasPrevPage ? page - 1 : null,\n totalDocs,\n totalPages,\n values: await getValues(),\n }\n }\n\n const values = await getValues()\n\n return {\n hasNextPage: false,\n hasPrevPage: false,\n limit: 0,\n page: 1,\n pagingCounter: 1,\n totalDocs: values.length,\n totalPages: 1,\n values,\n }\n}\n"],"names":["getFieldByPath","buildQuery","buildSortParam","getCollection","getSession","sanitizeGroupID","id","_field","getSortAggregation","fieldPath","hasSortAggregationAndHasMany","sortDirection","sortProperty","resolvedSortProperty","findDistinct","args","collectionConfig","Model","adapter","collectionSlug","collection","where","sortAggregation","sort","config","payload","fields","flattenedFields","locale","field","timestamps","query","fieldPathResult","includeRelationships","path","pathHasLocalized","localizedPath","replace","page","Object","keys","currentFields","foundField","rels","tempPath","insideRelation","segments","split","i","length","segment","find","e","name","type","relationTo","push","collections","resolvedField","isHasManyValue","relationLookup","startsWith","sortWithoutRelationPrefix","lastFieldPath","at","reduce","acc","filter","each","$lookup","as","foreignModel","foreignField","from","localField","$unwind","$group","preserveNullAndEmptyArrays","_id","_sort","$max","pipeline","$match","$sort","Boolean","session","req","getValues","aggregate","then","res","map","JSON","parse","stringify","limit","$skip","$limit","countPipeline","$count","totalDocs","count","totalPages","Math","ceil","hasPrevPage","hasNextPage","pagingCounter","nextPage","prevPage","values"],"mappings":"AAGA,SAASA,cAAc,QAAQ,UAAS;AAIxC,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SAASC,UAAU,QAAQ,4BAA2B;AAEtD,MAAMC,kBAAkB,CAACC;IACvB,IAAIA,MAAM,OAAOA,OAAO,YAAY,YAAYA,IAAI;QAClD,OAAOA,GAAGC,MAAM;IAClB;IAEA,OAAOD;AACT;AAEA,MAAME,qBAAqB,CAAC,EAC1BC,SAAS,EACTC,4BAA4B,EAC5BC,aAAa,EACbC,YAAY,EAMb;IACC,IAAIC;IAEJ,IAAIH,8BAA8B;QAChC,IAAIE,iBAAiBH,WAAW;YAC9BI,uBAAuB,CAAC,UAAU,CAAC;QACrC,OAAO;YACLA,uBAAuB,CAAC,SAAS,CAAC;QACpC;IACF,OAAO;QACLA,uBAAuBD,iBAAiBH,YAAY,QAAQ;IAC9D;IAEA,OAAO;QAAE,CAAC,GAAGI,sBAAsB,CAAC,EAAEF;IAAc;AACtD;AAEA,OAAO,MAAMG,eAA6B,eAAuCC,IAAI;IACnF,MAAM,EAAEC,gBAAgB,EAAEC,KAAK,EAAE,GAAGd,cAAc;QAChDe,SAAS,IAAI;QACbC,gBAAgBJ,KAAKK,UAAU;IACjC;IAEA,MAAM,EAAEC,QAAQ,CAAC,CAAC,EAAE,GAAGN;IAEvB,IAAIO,kBAAmC,E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AED,MAAMC,YAAY,MAAMnF,MAAMuE,SAAS,CAACU,eAAe;YACrDb;QACF,GAAGI,IAAI,CAAC,CAACC,MAAQA,GAAG,CAAC,EAAE,EAAEW,SAAS;QAClC,MAAMC,aAAaC,KAAKC,IAAI,CAACJ,YAAYrF,KAAKgF,KAAK;QACnD,MAAMU,cAAcnE,OAAO;QAC3B,MAAMoE,cAAcJ,aAAahE;QACjC,MAAMqE,gBAAgB,AAACrE,CAAAA,OAAO,CAAA,IAAKvB,KAAKgF,KAAK,GAAG;QAEhD,OAAO;YACLW;YACAD;YACAV,OAAOhF,KAAKgF,KAAK;YACjBa,UAAUF,cAAcpE,OAAO,IAAI;YACnCA;YACAqE;YACAE,UAAUJ,cAAcnE,OAAO,IAAI;YACnC8D;YACAE;YACAQ,QAAQ,MAAMvB;QAChB;IACF;IAEA,MAAMuB,SAAS,MAAMvB;IAErB,OAAO;QACLmB,aAAa;QACbD,aAAa;QACbV,OAAO;QACPzD,MAAM;QACNqE,eAAe;QACfP,WAAWU,OAAO7D,MAAM;QACxBqD,YAAY;QACZQ;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../src/findDistinct.ts"],"sourcesContent":["import type { PipelineStage } from 'mongoose'\nimport type { FindDistinct, FlattenedField } from 'payload'\n\nimport { getFieldByPath } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\n\nconst sanitizeGroupID = (id: any) => {\n if (id && typeof id === 'object' && '_field' in id) {\n return id._field\n }\n\n return id\n}\n\nconst getSortAggregation = ({\n fieldPath,\n hasSortAggregationAndHasMany,\n sortDirection,\n sortProperty,\n}: {\n fieldPath: string\n hasSortAggregationAndHasMany: boolean\n sortDirection: -1 | 1\n sortProperty: string\n}): Record<string, -1 | 1> => {\n let resolvedSortProperty: string\n\n if (hasSortAggregationAndHasMany) {\n if (sortProperty === fieldPath) {\n resolvedSortProperty = `_id._field`\n } else {\n resolvedSortProperty = `_id._sort`\n }\n } else {\n resolvedSortProperty = sortProperty === fieldPath ? '_id' : '_sort'\n }\n\n return { [`${resolvedSortProperty}`]: sortDirection }\n}\n\nexport const findDistinct: FindDistinct = async function (this: MongooseAdapter, args) {\n const { collectionConfig, Model } = getCollection({\n adapter: this,\n collectionSlug: args.collection,\n })\n\n const { where = {} } = args\n\n let sortAggregation: PipelineStage[] = []\n\n const sort = buildSortParam({\n adapter: this,\n config: this.payload.config,\n fields: collectionConfig.flattenedFields,\n locale: args.locale,\n sort: args.sort ?? args.field,\n sortAggregation,\n timestamps: true,\n })\n\n const query = await buildQuery({\n adapter: this,\n collectionSlug: args.collection,\n fields: collectionConfig.flattenedFields,\n locale: args.locale,\n where,\n })\n\n const fieldPathResult = getFieldByPath({\n config: this.payload.config,\n fields: collectionConfig.flattenedFields,\n includeRelationships: true,\n path: args.field,\n })\n let fieldPath = args.field\n if (fieldPathResult?.pathHasLocalized && args.locale) {\n fieldPath = fieldPathResult.localizedPath.replace('<locale>', args.locale)\n }\n\n const page = args.page || 1\n\n let sortProperty = Object.keys(sort)[0]! // assert because buildSortParam always returns at least 1 key.\n const sortDirection = sort[sortProperty] === 'asc' ? 1 : -1\n\n let currentFields = collectionConfig.flattenedFields\n let foundField: FlattenedField | null = null\n\n let rels: {\n fieldPath: string\n relationTo: string\n }[] = []\n\n let tempPath = ''\n let insideRelation = false\n\n const segments = args.field.split('.')\n\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i]\n const field = currentFields.find((e) => e.name === segment)\n if (rels.length) {\n insideRelation = true\n }\n\n if (!field) {\n break\n }\n\n if (tempPath) {\n tempPath = `${tempPath}.${field.name}`\n } else {\n tempPath = field.name\n }\n\n if ('flattenedFields' in field) {\n currentFields = field.flattenedFields\n continue\n }\n\n if (\n (field.type === 'relationship' || field.type === 'upload') &&\n typeof field.relationTo === 'string'\n ) {\n if (i === segments.length - 2 && segments[i + 1] === 'id') {\n foundField = field\n fieldPath = tempPath\n break\n }\n rels.push({ fieldPath: tempPath, relationTo: field.relationTo })\n currentFields = this.payload.collections[field.relationTo]?.config\n .flattenedFields as FlattenedField[]\n continue\n }\n foundField = field\n }\n\n const resolvedField = foundField || fieldPathResult?.field\n const isHasManyValue = resolvedField && 'hasMany' in resolvedField && resolvedField\n\n let relationLookup: null | PipelineStage[] = null\n\n if (!insideRelation) {\n rels = []\n }\n\n if (rels.length) {\n if (sortProperty.startsWith('_')) {\n const sortWithoutRelationPrefix = sortProperty.replace(/^_+/, '')\n const lastFieldPath = rels.at(-1)?.fieldPath as string\n if (sortWithoutRelationPrefix.startsWith(lastFieldPath)) {\n sortProperty = sortWithoutRelationPrefix\n }\n }\n relationLookup = []\n for (const { fieldPath, relationTo } of rels) {\n sortAggregation = sortAggregation.filter((each) => {\n if ('$lookup' in each && each.$lookup.as.replace(/^_+/, '') === fieldPath) {\n return false\n }\n\n return true\n })\n const { collectionConfig: foreignCollectionConfig, Model: foreignModel } = getCollection({\n adapter: this,\n collectionSlug: relationTo,\n })\n const relatedAccess = args.relatedAccess?.[fieldPath]\n const relatedAccessQuery = relatedAccess\n ? await buildQuery({\n adapter: this,\n collectionSlug: relationTo,\n fields: foreignCollectionConfig.flattenedFields,\n locale: args.locale,\n where: relatedAccess,\n })\n : null\n\n relationLookup.push({\n $lookup: {\n as: fieldPath,\n from: foreignModel.collection.name,\n ...(relatedAccessQuery\n ? {\n let: { relatedIDs: `$${fieldPath}` },\n pipeline: [\n {\n $match: {\n $and: [\n {\n $expr: {\n $cond: {\n else: { $eq: ['$_id', '$$relatedIDs'] },\n if: { $isArray: '$$relatedIDs' },\n then: { $in: ['$_id', '$$relatedIDs'] },\n },\n },\n },\n relatedAccessQuery,\n ],\n },\n },\n ],\n }\n : {\n foreignField: '_id',\n localField: fieldPath,\n }),\n },\n })\n relationLookup.push({ $unwind: `$${fieldPath}` })\n }\n }\n\n let $unwind: any = ''\n let $group: any = null\n if (\n isHasManyValue &&\n sortAggregation.length &&\n sortAggregation[0] &&\n '$lookup' in sortAggregation[0]\n ) {\n $unwind = { path: `$${sortAggregation[0].$lookup.as}`, preserveNullAndEmptyArrays: true }\n $group = {\n _id: {\n _field: `$${sortAggregation[0].$lookup.as}._id`,\n _sort: `$${sortProperty}`,\n },\n }\n } else if (isHasManyValue) {\n $unwind = { path: `$${args.field}`, preserveNullAndEmptyArrays: true }\n }\n\n if (!$group) {\n $group = {\n _id: `$${fieldPath}`,\n ...(sortProperty === fieldPath\n ? {}\n : {\n _sort: { $max: `$${sortProperty}` },\n }),\n }\n }\n\n const pipeline: PipelineStage[] = [\n {\n $match: query,\n },\n ...(sortAggregation.length > 0 ? sortAggregation : []),\n ...(relationLookup?.length ? relationLookup : []),\n ...($unwind\n ? [\n {\n $unwind,\n },\n ]\n : []),\n {\n $group,\n },\n {\n $sort: getSortAggregation({\n fieldPath,\n hasSortAggregationAndHasMany: Boolean(isHasManyValue) && Boolean(sortAggregation.length),\n sortDirection,\n sortProperty,\n }),\n },\n ]\n\n const session = await getSession(this, args.req)\n\n const getValues = async () => {\n return Model.aggregate(pipeline, { session }).then((res) =>\n res.map((each) => ({\n [args.field]: JSON.parse(JSON.stringify(sanitizeGroupID(each._id))),\n })),\n )\n }\n\n if (args.limit) {\n pipeline.push({\n $skip: (page - 1) * args.limit,\n })\n pipeline.push({ $limit: args.limit })\n\n // Build count pipeline with the same structure as the main pipeline\n // to ensure relationship lookups are included\n const countPipeline: PipelineStage[] = [\n {\n $match: query,\n },\n ...(sortAggregation.length > 0 ? sortAggregation : []),\n ...(relationLookup?.length ? relationLookup : []),\n ...($unwind\n ? [\n {\n $unwind,\n },\n ]\n : []),\n {\n $group,\n },\n { $count: 'count' },\n ]\n\n const totalDocs = await Model.aggregate(countPipeline, {\n session,\n }).then((res) => res[0]?.count ?? 0)\n const totalPages = Math.ceil(totalDocs / args.limit)\n const hasPrevPage = page > 1\n const hasNextPage = totalPages > page\n const pagingCounter = (page - 1) * args.limit + 1\n\n return {\n hasNextPage,\n hasPrevPage,\n limit: args.limit,\n nextPage: hasNextPage ? page + 1 : null,\n page,\n pagingCounter,\n prevPage: hasPrevPage ? page - 1 : null,\n totalDocs,\n totalPages,\n values: await getValues(),\n }\n }\n\n const values = await getValues()\n\n return {\n hasNextPage: false,\n hasPrevPage: false,\n limit: 0,\n page: 1,\n pagingCounter: 1,\n totalDocs: values.length,\n totalPages: 1,\n values,\n }\n}\n"],"names":["getFieldByPath","buildQuery","buildSortParam","getCollection","getSession","sanitizeGroupID","id","_field","getSortAggregation","fieldPath","hasSortAggregationAndHasMany","sortDirection","sortProperty","resolvedSortProperty","findDistinct","args","collectionConfig","Model","adapter","collectionSlug","collection","where","sortAggregation","sort","config","payload","fields","flattenedFields","locale","field","timestamps","query","fieldPathResult","includeRelationships","path","pathHasLocalized","localizedPath","replace","page","Object","keys","currentFields","foundField","rels","tempPath","insideRelation","segments","split","i","length","segment","find","e","name","type","relationTo","push","collections","resolvedField","isHasManyValue","relationLookup","startsWith","sortWithoutRelationPrefix","lastFieldPath","at","filter","each","$lookup","as","foreignCollectionConfig","foreignModel","relatedAccess","relatedAccessQuery","from","let","relatedIDs","pipeline","$match","$and","$expr","$cond","else","$eq","if","$isArray","then","$in","foreignField","localField","$unwind","$group","preserveNullAndEmptyArrays","_id","_sort","$max","$sort","Boolean","session","req","getValues","aggregate","res","map","JSON","parse","stringify","limit","$skip","$limit","countPipeline","$count","totalDocs","count","totalPages","Math","ceil","hasPrevPage","hasNextPage","pagingCounter","nextPage","prevPage","values"],"mappings":"AAGA,SAASA,cAAc,QAAQ,UAAS;AAIxC,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SAASC,UAAU,QAAQ,4BAA2B;AAEtD,MAAMC,kBAAkB,CAACC;IACvB,IAAIA,MAAM,OAAOA,OAAO,YAAY,YAA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,GACD,EAAE;YACN;gBACEC;YACF;YACA;gBAAEoB,QAAQ;YAAQ;SACnB;QAED,MAAMC,YAAY,MAAM9F,MAAMmF,SAAS,CAACS,eAAe;YACrDZ;QACF,GAAGZ,IAAI,CAAC,CAACgB,MAAQA,GAAG,CAAC,EAAE,EAAEW,SAAS;QAClC,MAAMC,aAAaC,KAAKC,IAAI,CAACJ,YAAYhG,KAAK2F,KAAK;QACnD,MAAMU,cAAc9E,OAAO;QAC3B,MAAM+E,cAAcJ,aAAa3E;QACjC,MAAMgF,gBAAgB,AAAChF,CAAAA,OAAO,CAAA,IAAKvB,KAAK2F,KAAK,GAAG;QAEhD,OAAO;YACLW;YACAD;YACAV,OAAO3F,KAAK2F,KAAK;YACjBa,UAAUF,cAAc/E,OAAO,IAAI;YACnCA;YACAgF;YACAE,UAAUJ,cAAc9E,OAAO,IAAI;YACnCyE;YACAE;YACAQ,QAAQ,MAAMtB;QAChB;IACF;IAEA,MAAMsB,SAAS,MAAMtB;IAErB,OAAO;QACLkB,aAAa;QACbD,aAAa;QACbV,OAAO;QACPpE,MAAM;QACNgF,eAAe;QACfP,WAAWU,OAAOxE,MAAM;QACxBgE,YAAY;QACZQ;IACF;AACF,EAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AACnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EACV,cAAc,EACd,YAAY,EACZ,aAAa,EACd,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EACV,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,UAAU,EAEV,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,aAAa,EACb,iBAA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AAY,EAAE,eAAe,EAC7B,iBAAiB,EACjB,cAAc,EACd,kBAAuB,EACvB,GAAG,EACH,0BAAkC,EAClC,qBAA6B,EAC7B,mBAA0B,EAC1B,uBAA8B,GAC/B,EAAE,IAAI,GAAG,kBAAkB,CAmF3B;AAED,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollationOptions, TransactionOptions } from 'mongodb'\nimport type { MongoMemoryReplSet } from 'mongodb-memory-server'\nimport type {\n ClientSession,\n Connection,\n ConnectOptions,\n QueryOptions,\n SchemaOptions,\n} from 'mongoose'\nimport type {\n BaseDatabaseAdapter,\n CollectionSlug,\n DatabaseAdapterObj,\n JsonObject,\n Payload,\n TypeWithVersion,\n UpdateGlobalArgs,\n UpdateGlobalVersionArgs,\n UpdateOneArgs,\n UpdateVersionArgs,\n} from 'payload'\n\nimport mongoose from 'mongoose'\nimport { createDatabaseAdapter, defaultBeginTransaction, findMigrationDir } from 'payload'\n\nimport type {\n CollectionModel,\n GlobalModel,\n MigrateDownArgs,\n MigrateUpArgs,\n MongooseMigration,\n} from './types.js'\n\nimport { connect } from './connect.js'\nimport { count } from './count.js'\nimport { countGlobalVersions } from './countGlobalVersions.js'\nimport { countVersions } from './countVersions.js'\nimport { create } from './create.js'\nimport { createGlobal } from './createGlobal.js'\nimport { createGlobalVersion } from './createGlobalVersion.js'\nimport { createMigration } from './createMigration.js'\nimport { createVersion } from './createVersion.js'\nimport { deleteMany } from './deleteMany.js'\nimport { deleteOne } from './deleteOne.js'\nimport { deleteVersions } from './deleteVersions.js'\nimport { destroy } from './destroy.js'\nimport { find } from './find.js'\nimport { findDistinct } from './findDistinct.js'\nimport { findGlobal } from './findGlobal.js'\nimport { findGlobalVersions } from './findGlobalVersions.js'\nimport { findOne } from './findOne.js'\nimport { findVersions } from './findVersions.js'\nimport { init } from './init.js'\nimport { migrateFresh } from './migrateFresh.js'\nimport { queryDrafts } from './queryDrafts.js'\nimport { beginTransaction } from './transactions/beginTransaction.js'\nimport { commitTransaction } from './transactions/commitTransaction.js'\nimport { rollbackTransaction } from './transactions/rollbackTransaction.js'\nimport { updateGlobal } from './updateGlobal.js'\nimport { updateGlobalVersion } from './updateGlobalVersion.js'\nimport { updateJobs } from './updateJobs.js'\nimport { updateMany } from './updateMany.js'\nimport { updateOne } from './updateOne.js'\nimport { updateVersion } from './updateVersion.js'\nimport { upsert } from './upsert.js'\n\nexport type { MigrateDownArgs, MigrateUpArgs } from './types.js'\n\nexport interface Args {\n afterCreateConnection?: (adapter: MongooseAdapter) => Promise<void> | void\n afterOpenConnection?: (adapter: MongooseAdapter) => Promise<void> | void\n /**\n * By default, Payload strips all additional keys from MongoDB data that don't exist\n * in the Payload schema. If you have some data that you want to include to the result\n * but it doesn't exist in Payload, you can enable this flag\n * @default false\n */\n allowAdditionalKeys?: boolean\n /**\n * Enable this flag if you want to thread your own ID to create operation data, for example:\n * ```ts\n * import { Types } from 'mongoose'\n *\n * const id = new Types.ObjectId().toHexString()\n * const doc = await payload.create({ collection: 'posts', data: {id, title: \"my title\"}})\n * assertEq(doc.id, id)\n * ```\n */\n allowIDOnCreate?: boolean\n /** Set to false to disable auto-pluralization of collection names, Defaults to true */\n autoPluralization?: boolean\n /**\n * When true, bulk operations will process documents one at a time\n * in separate transactions instead of all at once in a single transaction.\n * Useful for avoiding transaction limitations with large datasets in DocumentDB and Cosmos DB.\n *\n * @default false\n */\n bulkOperationsSingleTransaction?: boolean\n\n /**\n * If enabled, collation allows for language-specific rules for string comparison.\n * This configuration can include the following options:\n *\n * - `strength` (number): Comparison level (1: Primary, 2: Secondary, 3: Tertiary (default), 4: Quaternary, 5: Identical)\n * - `caseLevel` (boolean): Include case comparison at strength level 1 or 2.\n * - `caseFirst` (string): Sort order of case differences during tertiary level comparisons (\"upper\", \"lower\", \"off\").\n * - `numericOrdering` (boolean): Compare numeric strings as numbers.\n * - `alternate` (string): Consider whitespace and punctuation as base characters (\"non-ignorable\", \"shifted\").\n * - `maxVariable` (string): Characters considered ignorable when `alternate` is \"shifted\" (\"punct\", \"space\").\n * - `backwards` (boolean): Sort strings with diacritics from back of the string.\n * - `normalization` (boolean): Check if text requires normalization and perform normalization.\n *\n * Available on MongoDB version 3.4 and up.\n * The locale that gets passed is your current project's locale but defaults to \"en\".\n *\n * Example:\n * {\n * strength: 3\n * }\n *\n * Defaults to disabled.\n */\n collation?: Omit<CollationOptions, 'locale'>\n\n collectionsSchemaOptions?: Partial<Record<CollectionSlug, SchemaOptions>>\n /** Extra configuration options */\n connectOptions?: ConnectOptions\n /**\n * We add a secondary sort based on `createdAt` to ensure that results are always returned in the same order when sorting by a non-unique field.\n * This is because MongoDB does not guarantee the order of results, however in very large datasets this could affect performance.\n *\n * Set to `true` to disable this behaviour.\n */\n disableFallbackSort?: boolean\n /** Set to true to disable hinting to MongoDB to use 'id' as index. This is currently done when counting documents for pagination. Disabling this optimization might fix some problems with AWS DocumentDB. Defaults to false */\n disableIndexHints?: boolean\n /**\n * Set to `true` to ensure that indexes are ready before completing connection.\n * NOTE: not recommended for production. This can slow down the initialization of Payload.\n */\n ensureIndexes?: boolean\n migrationDir?: string\n /**\n * typed as any to avoid dependency\n */\n mongoMemoryServer?: MongoMemoryReplSet\n prodMigrations?: MongooseMigration[]\n\n transactionOptions?: false | TransactionOptions\n\n /** The URL to connect to MongoDB or false to start payload and prevent connecting */\n url: false | string\n\n /**\n * Set to `true` to use an alternative `dropDatabase` implementation that calls `collection.deleteMany({})` on every collection instead of sending a raw `dropDatabase` command.\n * Payload only uses `dropDatabase` for testing purposes.\n * @default false\n */\n useAlternativeDropDatabase?: boolean\n\n /**\n * Set to `true` to use `BigInt` for custom ID fields of type `'number'`.\n * Useful for databases that don't support `double` or `int32` IDs.\n * @default false\n */\n useBigIntForNumberIDs?: boolean\n /**\n * Set to `false` to disable join aggregations (which use correlated subqueries) and instead populate join fields via multiple `find` queries.\n * @default true\n */\n useJoinAggregations?: boolean\n /**\n * Set to `false` to disable the use of `pipeline` in the `$lookup` aggregation in sorting.\n * @default true\n */\n usePipelineInSortLookup?: boolean\n}\n\nexport type MongooseAdapter = {\n afterCreateConnection?: (adapter: MongooseAdapter) => Promise<void> | void\n afterOpenConnection?: (adapter: MongooseAdapter) => Promise<void> | void\n bulkOperationsSingleTransaction: boolean\n collections: {\n [slug: string]: CollectionModel\n }\n connection: Connection\n ensureIndexes: boolean\n globals: GlobalModel\n mongoMemoryServer: MongoMemoryReplSet\n prodMigrations?: {\n down: (args: MigrateDownArgs) => Promise<void>\n name: string\n up: (args: MigrateUpArgs) => Promise<void>\n }[]\n sessions: Record<number | string, ClientSession>\n useAlternativeDropDatabase: boolean\n useBigIntForNumberIDs: boolean\n useJoinAggregations: boolean\n usePipelineInSortLookup: boolean\n versions: {\n [slug: string]: CollectionModel\n }\n} & Args &\n BaseDatabaseAdapter\n\ndeclare module 'payload' {\n export interface DatabaseAdapter\n extends Omit<BaseDatabaseAdapter, 'sessions'>,\n Omit<Args, 'migrationDir'> {\n collections: {\n [slug: string]: CollectionModel\n }\n connection: Connection\n ensureIndexes: boolean\n globals: GlobalModel\n mongoMemoryServer: MongoMemoryReplSet\n prodMigrations?: {\n down: (args: MigrateDownArgs) => Promise<void>\n name: string\n up: (args: MigrateUpArgs) => Promise<void>\n }[]\n sessions: Record<number | string, ClientSession>\n transactionOptions: TransactionOptions\n updateGlobal: <T extends Record<string, unknown>>(\n args: { options?: QueryOptions } & UpdateGlobalArgs<T>,\n ) => Promise<T>\n updateGlobalVersion: <T extends JsonObject = JsonObject>(\n args: { options?: QueryOptions } & UpdateGlobalVersionArgs<T>,\n ) => Promise<TypeWithVersion<T>>\n\n updateOne: (args: { options?: QueryOptions } & UpdateOneArgs) => Promise<Document>\n updateVersion: <T extends JsonObject = JsonObject>(\n args: { options?: QueryOptions } & UpdateVersionArgs<T>,\n ) => Promise<TypeWithVersion<T>>\n useAlternativeDropDatabase: boolean\n useBigIntForNumberIDs: boolean\n useJoinAggregations: boolean\n usePipelineInSortLookup: boolean\n versions: {\n [slug: string]: CollectionModel\n }\n }\n}\n\nexport function mongooseAdapter({\n afterCreateConnection,\n afterOpenConnection,\n allowAdditionalKeys = false,\n allowIDOnCreate = false,\n autoPluralization = true,\n bulkOperationsSingleTransaction = false,\n collation,\n collectionsSchemaOptions = {},\n connectOptions,\n disableFallbackSort = false,\n disableIndexHints = false,\n ensureIndexes = false,\n migrationDir: migrationDirArg,\n mongoMemoryServer,\n prodMigrations,\n transactionOptions = {},\n url,\n useAlternativeDropDatabase = false,\n useBigIntForNumberIDs = false,\n useJoinAggregations = true,\n usePipelineInSortLookup = true,\n}: Args): DatabaseAdapterObj {\n function adapter({ payload }: { payload: Payload }) {\n const migrationDir = findMigrationDir(migrationDirArg)\n mongoose.set('strictQuery', false)\n\n return createDatabaseAdapter<MongooseAdapter>({\n name: 'mongoose',\n\n // Mongoose-specific\n afterCreateConnection,\n afterOpenConnection,\n autoPluralization,\n bulkOperationsSingleTransaction,\n collation,\n collections: {},\n // @ts-expect-error initialize without a connection\n connection: undefined,\n connectOptions: connectOptions || {},\n disableIndexHints,\n ensureIndexes,\n // @ts-expect-error don't have globals model yet\n globals: undefined,\n // @ts-expect-error Should not be required\n mongoMemoryServer,\n sessions: {},\n transactionOptions: transactionOptions === false ? undefined : transactionOptions,\n updateJobs,\n updateMany,\n url,\n versions: {},\n // DatabaseAdapter\n allowAdditionalKeys,\n allowIDOnCreate,\n beginTransaction: transactionOptions === false ? defaultBeginTransaction() : beginTransaction,\n collectionsSchemaOptions,\n commitTransaction,\n connect,\n count,\n countGlobalVersions,\n countVersions,\n create,\n createGlobal,\n createGlobalVersion,\n createMigration,\n createVersion,\n defaultIDType: 'text',\n deleteMany,\n deleteOne,\n deleteVersions,\n destroy,\n disableFallbackSort,\n find,\n findDistinct,\n findGlobal,\n findGlobalVersions,\n findOne,\n findVersions,\n init,\n migrateFresh,\n migrationDir,\n packageName: '@payloadcms/db-mongodb',\n payload,\n prodMigrations,\n queryDrafts,\n rollbackTransaction,\n updateGlobal,\n updateGlobalVersion,\n updateOne,\n updateVersion,\n upsert,\n useAlternativeDropDatabase,\n useBigIntForNumberIDs,\n useJoinAggregations,\n usePipelineInSortLookup,\n })\n }\n\n return {\n name: 'mongoose',\n allowIDOnCreate,\n defaultIDType: 'text',\n init: adapter,\n }\n}\n\nexport { compatibilityOptions } from './utilities/compatibilityOptions.js'\n"],"names":["mongoose","createDatabaseAdapter","defaultBeginTransaction","findMigrationDir","connect","count","countGlobalVersions","countVersions","create","createGlobal","createGlobalVersion","createMigration","createVersion","deleteMany","deleteOne","deleteVersions","destroy","find","findDistinct","findGlobal","findGlobalVersions","findOne","findVersions","init","migrateFresh","queryDrafts","beginTransaction","commitTransaction","rollbackTransaction","updateGlobal","updateGlobalVersion","updateJobs","updateMany","updateOne","updateVersion","upsert","mongooseAdapter","afterCreateConnection","afterOpenConnection","allowAdditionalKeys","allowIDOnCreate","autoPluralization","bulkOperationsSingleTransaction","collation","collectionsSchemaOptions","connectOptions","disableFallbackSort","disableIndexHints","ensureIndexes","migrationDir","migrationDirArg","mongoMemoryServer","prodMigrations","transactionOptions","url","useAlternativeDropDatabase","useBigIntForNumberIDs","useJoinAggregations","usePipelineInSortLookup","adapter","payload","set","name","collections","connection","undefined","globals","sessions","versions","defaultIDType","packageName","compatibilityOptions"],"mappings":"AAsBA,OAAOA,cAAc,WAAU;AAC/B,SAASC,qBAAqB,EAAEC,uBAAuB,EAAEC,gBAAgB,QAAQ,UAAS;AAU1F,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,KAAK,QAAQ,aAAY;AAClC,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,MAAM,QAAQ,cAAa;AACpC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,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C,wBAAwB,KAAK,EAC7BC,sBAAsB,IAAI,EAC1BC,0BAA0B,IAAI,EACzB;IACL,SAASC,QAAQ,EAAEC,OAAO,EAAwB;QAChD,MAAMX,eAAe9C,iBAAiB+C;QACtClD,SAAS6D,GAAG,CAAC,eAAe;QAE5B,OAAO5D,sBAAuC;YAC5C6D,MAAM;YAEN,oBAAoB;YACpBzB;YACAC;YACAG;YACAC;YACAC;YACAoB,aAAa,CAAC;YACd,mDAAmD;YACnDC,YAAYC;YACZpB,gBAAgBA,kBAAkB,CAAC;YACnCE;YACAC;YACA,gDAAgD;YAChDkB,SAASD;YACT,0CAA0C;YAC1Cd;YACAgB,UAAU,CAAC;YACXd,oBAAoBA,uBAAuB,QAAQY,YAAYZ;YAC/DtB;YACAC;YACAsB;YACAc,UAAU,CAAC;YACX,kBAAkB;YAClB7B;YACAC;YACAd,kBAAkB2B,uBAAuB,QAAQnD,4BAA4BwB;YAC7EkB;YACAjB;YACAvB;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAyD,eAAe;YACfxD;YACAC;YACAC;YACAC;YACA8B;YACA7B;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAyB;YACAqB,aAAa;YACbV;YACAR;YACA3B;YACAG;YACAC;YACAC;YACAG;YACAC;YACAC;YACAoB;YACAC;YACAC;YACAC;QACF;IACF;IAEA,OAAO;QACLI,MAAM;QACNtB;QACA6B,eAAe;QACf9C,MAAMoC;IACR;AACF;AAEA,SAASY,oBAAoB,QAAQ,sCAAqC"}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollationOptions, TransactionOptions } from 'mongodb'\nimport type { MongoMemoryReplSet } from 'mongodb-memory-server'\nimport type {\n ClientSession,\n Connection,\n ConnectOptions,\n QueryOptions,\n SchemaOptions,\n} from 'mongoose'\nimport type {\n BaseDatabaseAdapter,\n CollectionSlug,\n DatabaseAdapterObj,\n JsonObject,\n Payload,\n TypeWithVersion,\n UpdateGlobalArgs,\n UpdateGlobalVersionArgs,\n UpdateOneArgs,\n UpdateVersionArgs,\n} from 'payload'\n\nimport mongoose from 'mongoose'\nimport { createDatabaseAdapter, defaultBeginTransaction, findMigrationDir } from 'payload'\n\nimport type {\n CollectionModel,\n GlobalModel,\n MigrateDownArgs,\n MigrateUpArgs,\n MongooseMigration,\n} from './types.js'\n\nimport { connect } from './connect.js'\nimport { count } from './count.js'\nimport { countGlobalVersions } from './countGlobalVersions.js'\nimport { countVersions } from './countVersions.js'\nimport { create } from './create.js'\nimport { createGlobal } from './createGlobal.js'\nimport { createGlobalVersion } from './createGlobalVersion.js'\nimport { createMigration } from './createMigration.js'\nimport { createVersion } from './createVersion.js'\nimport { deleteMany } from './deleteMany.js'\nimport { deleteOne } from './deleteOne.js'\nimport { deleteVersions } from './deleteVersions.js'\nimport { destroy } from './destroy.js'\nimport { find } from './find.js'\nimport { findDistinct } from './findDistinct.js'\nimport { findGlobal } from './findGlobal.js'\nimport { findGlobalVersions } from './findGlobalVersions.js'\nimport { findOne } from './findOne.js'\nimport { findVersions } from './findVersions.js'\nimport { init } from './init.js'\nimport { migrateFresh } from './migrateFresh.js'\nimport { queryDrafts } from './queryDrafts.js'\nimport { beginTransaction } from './transactions/beginTransaction.js'\nimport { commitTransaction } from './transactions/commitTransaction.js'\nimport { rollbackTransaction } from './transactions/rollbackTransaction.js'\nimport { updateGlobal } from './updateGlobal.js'\nimport { updateGlobalVersion } from './updateGlobalVersion.js'\nimport { updateJobs } from './updateJobs.js'\nimport { updateMany } from './updateMany.js'\nimport { updateOne } from './updateOne.js'\nimport { updateVersion } from './updateVersion.js'\nimport { upsert } from './upsert.js'\n\nexport type { MigrateDownArgs, MigrateUpArgs } from './types.js'\n\nexport interface Args {\n afterCreateConnection?: (adapter: MongooseAdapter) => Promise<void> | void\n afterOpenConnection?: (adapter: MongooseAdapter) => Promise<void> | void\n /**\n * By default, Payload strips all additional keys from MongoDB data that don't exist\n * in the Payload schema. If you have some data that you want to include to the result\n * but it doesn't exist in Payload, you can enable this flag\n * @default false\n */\n allowAdditionalKeys?: boolean\n /**\n * Enable this flag if you want to thread your own ID to create operation data, for example:\n * ```ts\n * import { Types } from 'mongoose'\n *\n * const id = new Types.ObjectId().toHexString()\n * const doc = await payload.create({ collection: 'posts', data: {id, title: \"my title\"}})\n * assertEq(doc.id, id)\n * ```\n */\n allowIDOnCreate?: boolean\n /** Set to false to disable auto-pluralization of collection names, Defaults to true */\n autoPluralization?: boolean\n /**\n * When true, bulk operations will process documents one at a time\n * in separate transactions instead of all at once in a single transaction.\n * Useful for avoiding transaction limitations with large datasets in DocumentDB and Cosmos DB.\n *\n * @default false\n */\n bulkOperationsSingleTransaction?: boolean\n\n /**\n * If enabled, collation allows for language-specific rules for string comparison.\n * This configuration can include the following options:\n *\n * - `strength` (number): Comparison level (1: Primary, 2: Secondary, 3: Tertiary (default), 4: Quaternary, 5: Identical)\n * - `caseLevel` (boolean): Include case comparison at strength level 1 or 2.\n * - `caseFirst` (string): Sort order of case differences during tertiary level comparisons (\"upper\", \"lower\", \"off\").\n * - `numericOrdering` (boolean): Compare numeric strings as numbers.\n * - `alternate` (string): Consider whitespace and punctuation as base characters (\"non-ignorable\", \"shifted\").\n * - `maxVariable` (string): Characters considered ignorable when `alternate` is \"shifted\" (\"punct\", \"space\").\n * - `backwards` (boolean): Sort strings with diacritics from back of the string.\n * - `normalization` (boolean): Check if text requires normalization and perform normalization.\n *\n * Available on MongoDB version 3.4 and up.\n * The locale that gets passed is your current project's locale but defaults to \"en\".\n *\n * Example:\n * {\n * strength: 3\n * }\n *\n * Defaults to disabled.\n */\n collation?: Omit<CollationOptions, 'locale'>\n\n collectionsSchemaOptions?: Partial<Record<CollectionSlug, SchemaOptions>>\n /** Extra configuration options */\n connectOptions?: ConnectOptions\n /**\n * We add a secondary sort based on `createdAt` to ensure that results are always returned in the same order when sorting by a non-unique field.\n * This is because MongoDB does not guarantee the order of results, however in very large datasets this could affect performance.\n *\n * Set to `true` to disable this behaviour.\n */\n disableFallbackSort?: boolean\n /** Set to true to disable hinting to MongoDB to use 'id' as index. This is currently done when counting documents for pagination. Disabling this optimization might fix some problems with AWS DocumentDB. Defaults to false */\n disableIndexHints?: boolean\n /**\n * Set to `true` to ensure that indexes are ready before completing connection.\n * NOTE: not recommended for production. This can slow down the initialization of Payload.\n */\n ensureIndexes?: boolean\n migrationDir?: string\n /**\n * typed as any to avoid dependency\n */\n mongoMemoryServer?: MongoMemoryReplSet\n prodMigrations?: MongooseMigration[]\n\n transactionOptions?: false | TransactionOptions\n\n /** The URL to connect to MongoDB or false to start payload and prevent connecting */\n url: false | string\n\n /**\n * Set to `true` to use an alternative `dropDatabase` implementation that calls `collection.deleteMany({})` on every collection instead of sending a raw `dropDatabase` command.\n * Payload only uses `dropDatabase` for testing purposes.\n * @default false\n */\n useAlternativeDropDatabase?: boolean\n\n /**\n * Set to `true` to use `BigInt` for custom ID fields of type `'number'`.\n * Useful for databases that don't support `double` or `int32` IDs.\n * @default false\n */\n useBigIntForNumberIDs?: boolean\n /**\n * Set to `false` to disable join aggregations (which use correlated subqueries) and instead populate join fields via multiple `find` queries.\n * @default true\n */\n useJoinAggregations?: boolean\n /**\n * Set to `false` to disable the use of `pipeline` in the `$lookup` aggregation in sorting.\n * @default true\n */\n usePipelineInSortLookup?: boolean\n}\n\nexport type MongooseAdapter = {\n afterCreateConnection?: (adapter: MongooseAdapter) => Promise<void> | void\n afterOpenConnection?: (adapter: MongooseAdapter) => Promise<void> | void\n bulkOperationsSingleTransaction: boolean\n collections: {\n [slug: string]: CollectionModel\n }\n connection: Connection\n ensureIndexes: boolean\n globals: GlobalModel\n mongoMemoryServer: MongoMemoryReplSet\n prodMigrations?: {\n down: (args: MigrateDownArgs) => Promise<void>\n name: string\n up: (args: MigrateUpArgs) => Promise<void>\n }[]\n sessions: Record<number | string, ClientSession>\n useAlternativeDropDatabase: boolean\n useBigIntForNumberIDs: boolean\n useJoinAggregations: boolean\n usePipelineInSortLookup: boolean\n versions: {\n [slug: string]: CollectionModel\n }\n} & Args &\n BaseDatabaseAdapter\n\ndeclare module 'payload' {\n export interface DatabaseAdapter\n extends Omit<BaseDatabaseAdapter, 'sessions'>, Omit<Args, 'migrationDir'> {\n collections: {\n [slug: string]: CollectionModel\n }\n connection: Connection\n ensureIndexes: boolean\n globals: GlobalModel\n mongoMemoryServer: MongoMemoryReplSet\n prodMigrations?: {\n down: (args: MigrateDownArgs) => Promise<void>\n name: string\n up: (args: MigrateUpArgs) => Promise<void>\n }[]\n sessions: Record<number | string, ClientSession>\n transactionOptions: TransactionOptions\n updateGlobal: <T extends Record<string, unknown>>(\n args: { options?: QueryOptions } & UpdateGlobalArgs<T>,\n ) => Promise<T>\n updateGlobalVersion: <T extends JsonObject = JsonObject>(\n args: { options?: QueryOptions } & UpdateGlobalVersionArgs<T>,\n ) => Promise<TypeWithVersion<T>>\n\n updateOne: (args: { options?: QueryOptions } & UpdateOneArgs) => Promise<Document>\n updateVersion: <T extends JsonObject = JsonObject>(\n args: { options?: QueryOptions } & UpdateVersionArgs<T>,\n ) => Promise<TypeWithVersion<T>>\n useAlternativeDropDatabase: boolean\n useBigIntForNumberIDs: boolean\n useJoinAggregations: boolean\n usePipelineInSortLookup: boolean\n versions: {\n [slug: string]: CollectionModel\n }\n }\n}\n\nexport function mongooseAdapter({\n afterCreateConnection,\n afterOpenConnection,\n allowAdditionalKeys = false,\n allowIDOnCreate = false,\n autoPluralization = true,\n bulkOperationsSingleTransaction = false,\n collation,\n collectionsSchemaOptions = {},\n connectOptions,\n disableFallbackSort = false,\n disableIndexHints = false,\n ensureIndexes = false,\n migrationDir: migrationDirArg,\n mongoMemoryServer,\n prodMigrations,\n transactionOptions = {},\n url,\n useAlternativeDropDatabase = false,\n useBigIntForNumberIDs = false,\n useJoinAggregations = true,\n usePipelineInSortLookup = true,\n}: Args): DatabaseAdapterObj {\n function adapter({ payload }: { payload: Payload }) {\n const migrationDir = findMigrationDir(migrationDirArg)\n mongoose.set('strictQuery', false)\n\n return createDatabaseAdapter<MongooseAdapter>({\n name: 'mongoose',\n\n // Mongoose-specific\n afterCreateConnection,\n afterOpenConnection,\n autoPluralization,\n bulkOperationsSingleTransaction,\n collation,\n collections: {},\n // @ts-expect-error initialize without a connection\n connection: undefined,\n connectOptions: connectOptions || {},\n disableIndexHints,\n ensureIndexes,\n // @ts-expect-error don't have globals model yet\n globals: undefined,\n // @ts-expect-error Should not be required\n mongoMemoryServer,\n sessions: {},\n transactionOptions: transactionOptions === false ? undefined : transactionOptions,\n updateJobs,\n updateMany,\n url,\n versions: {},\n // DatabaseAdapter\n allowAdditionalKeys,\n allowIDOnCreate,\n beginTransaction: transactionOptions === false ? defaultBeginTransaction() : beginTransaction,\n collectionsSchemaOptions,\n commitTransaction,\n connect,\n count,\n countGlobalVersions,\n countVersions,\n create,\n createGlobal,\n createGlobalVersion,\n createMigration,\n createVersion,\n defaultIDType: 'text',\n deleteMany,\n deleteOne,\n deleteVersions,\n destroy,\n disableFallbackSort,\n find,\n findDistinct,\n findGlobal,\n findGlobalVersions,\n findOne,\n findVersions,\n init,\n migrateFresh,\n migrationDir,\n packageName: '@payloadcms/db-mongodb',\n payload,\n prodMigrations,\n queryDrafts,\n rollbackTransaction,\n updateGlobal,\n updateGlobalVersion,\n updateOne,\n updateVersion,\n upsert,\n useAlternativeDropDatabase,\n useBigIntForNumberIDs,\n useJoinAggregations,\n usePipelineInSortLookup,\n })\n }\n\n return {\n name: 'mongoose',\n allowIDOnCreate,\n defaultIDType: 'text',\n init: adapter,\n }\n}\n\nexport { compatibilityOptions } from './utilities/compatibilityOptions.js'\n"],"names":["mongoose","createDatabaseAdapter","defaultBeginTransaction","findMigrationDir","connect","count","countGlobalVersions","countVersions","create","createGlobal","createGlobalVersion","createMigration","createVersion","deleteMany","deleteOne","deleteVersions","destroy","find","findDistinct","findGlobal","findGlobalVersions","findOne","findVersions","init","migrateFresh","queryDrafts","beginTransaction","commitTransaction","rollbackTransaction","updateGlobal","updateGlobalVersion","updateJobs","updateMany","updateOne","updateVersion","upsert","mongooseAdapter","afterCreateConnection","afterOpenConnection","allowAdditionalKeys","allowIDOnCreate","autoPluralization","bulkOperationsSingleTransaction","collation","collectionsSchemaOptions","connectOptions","disableFallbackSort","disableIndexHints","ensureIndexes","migrationDir","migrationDirArg","mongoMemoryServer","prodMigrations","transactionOptions","url","useAlternativeDropDatabase","useBigIntForNumberIDs","useJoinAggregations","usePipelineInSortLookup","adapter","payload","set","name","collections","connection","undefined","globals","sessions","versions","defaultIDType","packageName","compatibilityOptions"],"mappings":"AAsBA,OAAOA,cAAc,WAAU;AAC/B,SAASC,qBAAqB,EAAEC,uBAAuB,EAAEC,gBAAgB,QAAQ,UAAS;AAU1F,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,KAAK,QAAQ,aAAY;AAClC,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,MAAM,QAAQ,cAAa;AACpC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,IAAI,QAAQ,YAAW;AAChC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,IAAI,QAAQ,YAAW;AAChC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,gBAAgB,QAAQ,qCAAoC;AACrE,S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B2B,uBAAuB,QAAQnD,4BAA4BwB;YAC7EkB;YACAjB;YACAvB;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAyD,eAAe;YACfxD;YACAC;YACAC;YACAC;YACA8B;YACA7B;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAyB;YACAqB,aAAa;YACbV;YACAR;YACA3B;YACAG;YACAC;YACAC;YACAG;YACAC;YACAC;YACAoB;YACAC;YACAC;YACAC;QACF;IACF;IAEA,OAAO;QACLI,MAAM;QACNtB;QACA6B,eAAe;QACf9C,MAAMoC;IACR;AACF;AAEA,SAASY,oBAAoB,QAAQ,sCAAqC"}
|
package/dist/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAA6B,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAA6B,MAAM,SAAS,CAAA;AAoB9D,eAAO,MAAM,IAAI,EAAE,IAqHlB,CAAA"}
|
package/dist/init.js
CHANGED
|
@@ -4,6 +4,7 @@ import { buildVersionCollectionFields, buildVersionCompoundIndexes, buildVersion
|
|
|
4
4
|
import { buildCollectionSchema } from './models/buildCollectionSchema.js';
|
|
5
5
|
import { buildGlobalModel } from './models/buildGlobalModel.js';
|
|
6
6
|
import { buildSchema } from './models/buildSchema.js';
|
|
7
|
+
import { createMongoSchemaBuildContext } from './models/schemaBuildContext.js';
|
|
7
8
|
import { getBuildQueryPlugin } from './queries/getBuildQueryPlugin.js';
|
|
8
9
|
import { getDBName } from './utilities/getDBName.js';
|
|
9
10
|
export const init = async function init() {
|
|
@@ -13,76 +14,97 @@ export const init = async function init() {
|
|
|
13
14
|
if (this.afterCreateConnection) {
|
|
14
15
|
await this.afterCreateConnection(this);
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const schema = buildCollectionSchema(collection, this.payload, schemaOptions);
|
|
19
|
-
if (collection.versions) {
|
|
20
|
-
const versionModelName = getDBName({
|
|
21
|
-
config: collection,
|
|
22
|
-
versions: true
|
|
23
|
-
});
|
|
24
|
-
const versionCollectionFields = buildVersionCollectionFields(this.payload.config, collection);
|
|
25
|
-
const versionSchema = buildSchema({
|
|
26
|
-
buildSchemaOptions: {
|
|
27
|
-
disableUnique: true,
|
|
28
|
-
draftsEnabled: true,
|
|
29
|
-
indexSortableFields: this.payload.config.indexSortableFields,
|
|
30
|
-
options: {
|
|
31
|
-
minimize: false,
|
|
32
|
-
timestamps: false,
|
|
33
|
-
...schemaOptions
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
compoundIndexes: buildVersionCompoundIndexes({
|
|
37
|
-
indexes: collection.sanitizedIndexes
|
|
38
|
-
}),
|
|
39
|
-
configFields: versionCollectionFields,
|
|
40
|
-
payload: this.payload
|
|
41
|
-
});
|
|
42
|
-
versionSchema.plugin(paginate, {
|
|
43
|
-
useEstimatedCount: true
|
|
44
|
-
}).plugin(getBuildQueryPlugin({
|
|
45
|
-
collectionSlug: collection.slug,
|
|
46
|
-
versionsFields: buildVersionCollectionFields(this.payload.config, collection, true)
|
|
47
|
-
}));
|
|
48
|
-
const versionCollectionName = this.autoPluralization === true && !collection.dbName ? undefined : versionModelName;
|
|
49
|
-
this.versions[collection.slug] = this.connection.model(versionModelName, versionSchema, versionCollectionName);
|
|
50
|
-
}
|
|
51
|
-
const modelName = getDBName({
|
|
52
|
-
config: collection
|
|
53
|
-
});
|
|
54
|
-
const collectionName = this.autoPluralization === true && !collection.dbName ? undefined : modelName;
|
|
55
|
-
this.collections[collection.slug] = this.connection.model(modelName, schema, collectionName);
|
|
17
|
+
const schemaBuildContext = createMongoSchemaBuildContext({
|
|
18
|
+
connection: this.connection
|
|
56
19
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
20
|
+
try {
|
|
21
|
+
this.payload.config.collections.forEach((collection)=>{
|
|
22
|
+
const schemaOptions = this.collectionsSchemaOptions?.[collection.slug];
|
|
23
|
+
const schema = buildCollectionSchema({
|
|
24
|
+
collection,
|
|
25
|
+
payload: this.payload,
|
|
26
|
+
schemaBuildContext,
|
|
27
|
+
schemaOptions
|
|
63
28
|
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
29
|
+
if (collection.versions) {
|
|
30
|
+
const versionModelName = getDBName({
|
|
31
|
+
config: collection,
|
|
32
|
+
versions: true
|
|
33
|
+
});
|
|
34
|
+
const versionCollectionFields = buildVersionCollectionFields(this.payload.config, collection);
|
|
35
|
+
const versionSchema = buildSchema({
|
|
36
|
+
buildSchemaOptions: {
|
|
37
|
+
disableUnique: true,
|
|
38
|
+
draftsEnabled: true,
|
|
39
|
+
indexSortableFields: this.payload.config.indexSortableFields,
|
|
40
|
+
options: {
|
|
41
|
+
minimize: false,
|
|
42
|
+
timestamps: false,
|
|
43
|
+
...schemaOptions
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
compoundIndexes: buildVersionCompoundIndexes({
|
|
47
|
+
indexes: collection.sanitizedIndexes
|
|
48
|
+
}),
|
|
49
|
+
configFields: versionCollectionFields,
|
|
50
|
+
isVersion: true,
|
|
51
|
+
payload: this.payload,
|
|
52
|
+
schemaBuildContext,
|
|
53
|
+
schemaPath: `collection:${collection.slug}`
|
|
54
|
+
});
|
|
55
|
+
versionSchema.plugin(paginate, {
|
|
56
|
+
useEstimatedCount: true
|
|
57
|
+
}).plugin(getBuildQueryPlugin({
|
|
58
|
+
collectionSlug: collection.slug,
|
|
59
|
+
versionsFields: buildVersionCollectionFields(this.payload.config, collection, true)
|
|
60
|
+
}));
|
|
61
|
+
const versionCollectionName = this.autoPluralization === true && !collection.dbName ? undefined : versionModelName;
|
|
62
|
+
this.versions[collection.slug] = this.connection.model(versionModelName, versionSchema, versionCollectionName);
|
|
63
|
+
}
|
|
64
|
+
const modelName = getDBName({
|
|
65
|
+
config: collection
|
|
77
66
|
});
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
67
|
+
const collectionName = this.autoPluralization === true && !collection.dbName ? undefined : modelName;
|
|
68
|
+
this.collections[collection.slug] = this.connection.model(modelName, schema, collectionName);
|
|
69
|
+
});
|
|
70
|
+
this.globals = buildGlobalModel({
|
|
71
|
+
adapter: this,
|
|
72
|
+
schemaBuildContext
|
|
73
|
+
});
|
|
74
|
+
this.payload.config.globals.forEach((global)=>{
|
|
75
|
+
if (global.versions) {
|
|
76
|
+
const versionModelName = getDBName({
|
|
77
|
+
config: global,
|
|
78
|
+
versions: true
|
|
79
|
+
});
|
|
80
|
+
const versionGlobalFields = buildVersionGlobalFields(this.payload.config, global);
|
|
81
|
+
const versionSchema = buildSchema({
|
|
82
|
+
buildSchemaOptions: {
|
|
83
|
+
disableUnique: true,
|
|
84
|
+
draftsEnabled: true,
|
|
85
|
+
indexSortableFields: this.payload.config.indexSortableFields,
|
|
86
|
+
options: {
|
|
87
|
+
minimize: false,
|
|
88
|
+
timestamps: false
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
configFields: versionGlobalFields,
|
|
92
|
+
isVersion: true,
|
|
93
|
+
payload: this.payload,
|
|
94
|
+
schemaBuildContext,
|
|
95
|
+
schemaPath: `global:${global.slug}`
|
|
96
|
+
});
|
|
97
|
+
versionSchema.plugin(paginate, {
|
|
98
|
+
useEstimatedCount: true
|
|
99
|
+
}).plugin(getBuildQueryPlugin({
|
|
100
|
+
versionsFields: buildVersionGlobalFields(this.payload.config, global, true)
|
|
101
|
+
}));
|
|
102
|
+
this.versions[global.slug] = this.connection.model(versionModelName, versionSchema, versionModelName);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
} finally{
|
|
106
|
+
schemaBuildContext.clear();
|
|
107
|
+
}
|
|
86
108
|
};
|
|
87
109
|
|
|
88
110
|
//# sourceMappingURL=init.js.map
|
package/dist/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/init.ts"],"sourcesContent":["import type { PaginateOptions } from 'mongoose'\nimport type { Init, SanitizedCollectionConfig } from 'payload'\n\nimport mongoose from 'mongoose'\nimport paginate from 'mongoose-paginate-v2'\nimport {\n buildVersionCollectionFields,\n buildVersionCompoundIndexes,\n buildVersionGlobalFields,\n} from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\nimport type { CollectionModel, GlobalModel } 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/getBuildQueryPlugin.js'\nimport { getDBName } from './utilities/getDBName.js'\n\nexport const init: Init = async function init(this: MongooseAdapter) {\n // Always create a scoped, **unopened** connection object\n // (no URI here; models compile per-connection and do not require an open socket)\n this.connection ??= mongoose.createConnection()\n\n if (this.afterCreateConnection) {\n await this.afterCreateConnection(this)\n }\n\n this.payload.config.collections.forEach((collection: SanitizedCollectionConfig) => {\n
|
|
1
|
+
{"version":3,"sources":["../src/init.ts"],"sourcesContent":["import type { PaginateOptions } from 'mongoose'\nimport type { Init, SanitizedCollectionConfig } from 'payload'\n\nimport mongoose from 'mongoose'\nimport paginate from 'mongoose-paginate-v2'\nimport {\n buildVersionCollectionFields,\n buildVersionCompoundIndexes,\n buildVersionGlobalFields,\n} from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\nimport type { CollectionModel, GlobalModel } from './types.js'\n\nimport { buildCollectionSchema } from './models/buildCollectionSchema.js'\nimport { buildGlobalModel } from './models/buildGlobalModel.js'\nimport { buildSchema } from './models/buildSchema.js'\nimport { createMongoSchemaBuildContext } from './models/schemaBuildContext.js'\nimport { getBuildQueryPlugin } from './queries/getBuildQueryPlugin.js'\nimport { getDBName } from './utilities/getDBName.js'\n\nexport const init: Init = async function init(this: MongooseAdapter) {\n // Always create a scoped, **unopened** connection object\n // (no URI here; models compile per-connection and do not require an open socket)\n this.connection ??= mongoose.createConnection()\n\n if (this.afterCreateConnection) {\n await this.afterCreateConnection(this)\n }\n\n const schemaBuildContext = createMongoSchemaBuildContext({ connection: this.connection })\n\n try {\n this.payload.config.collections.forEach((collection: SanitizedCollectionConfig) => {\n const schemaOptions = this.collectionsSchemaOptions?.[collection.slug]\n\n const schema = buildCollectionSchema({\n collection,\n payload: this.payload,\n schemaBuildContext,\n schemaOptions,\n })\n if (collection.versions) {\n const versionModelName = getDBName({ config: collection, versions: true })\n\n const versionCollectionFields = buildVersionCollectionFields(\n this.payload.config,\n collection,\n )\n\n const versionSchema = buildSchema({\n buildSchemaOptions: {\n disableUnique: true,\n draftsEnabled: true,\n indexSortableFields: this.payload.config.indexSortableFields,\n options: {\n minimize: false,\n timestamps: false,\n ...schemaOptions,\n },\n },\n compoundIndexes: buildVersionCompoundIndexes({ indexes: collection.sanitizedIndexes }),\n configFields: versionCollectionFields,\n isVersion: true,\n payload: this.payload,\n schemaBuildContext,\n schemaPath: `collection:${collection.slug}`,\n })\n\n versionSchema.plugin<any, PaginateOptions>(paginate, { useEstimatedCount: true }).plugin(\n getBuildQueryPlugin({\n collectionSlug: collection.slug,\n versionsFields: buildVersionCollectionFields(this.payload.config, collection, true),\n }),\n )\n\n const versionCollectionName =\n this.autoPluralization === true && !collection.dbName ? undefined : versionModelName\n\n this.versions[collection.slug] = this.connection.model(\n versionModelName,\n versionSchema,\n versionCollectionName,\n ) as unknown as CollectionModel\n }\n\n const modelName = getDBName({ config: collection })\n const collectionName =\n this.autoPluralization === true && !collection.dbName ? undefined : modelName\n\n this.collections[collection.slug] = this.connection.model<any>(\n modelName,\n schema,\n collectionName,\n ) as CollectionModel\n })\n\n this.globals = buildGlobalModel({ adapter: this, schemaBuildContext }) as GlobalModel\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(this.payload.config, global)\n\n const versionSchema = buildSchema({\n buildSchemaOptions: {\n disableUnique: true,\n draftsEnabled: true,\n indexSortableFields: this.payload.config.indexSortableFields,\n options: {\n minimize: false,\n timestamps: false,\n },\n },\n configFields: versionGlobalFields,\n isVersion: true,\n payload: this.payload,\n schemaBuildContext,\n schemaPath: `global:${global.slug}`,\n })\n\n versionSchema.plugin<any, PaginateOptions>(paginate, { useEstimatedCount: true }).plugin(\n getBuildQueryPlugin({\n versionsFields: buildVersionGlobalFields(this.payload.config, global, true),\n }),\n )\n\n this.versions[global.slug] = this.connection.model<any>(\n versionModelName,\n versionSchema,\n versionModelName,\n ) as CollectionModel\n }\n })\n } finally {\n schemaBuildContext.clear()\n }\n}\n"],"names":["mongoose","paginate","buildVersionCollectionFields","buildVersionCompoundIndexes","buildVersionGlobalFields","buildCollectionSchema","buildGlobalModel","buildSchema","createMongoSchemaBuildContext","getBuildQueryPlugin","getDBName","init","connection","createConnection","afterCreateConnection","schemaBuildContext","payload","config","collections","forEach","collection","schemaOptions","collectionsSchemaOptions","slug","schema","versions","versionModelName","versionCollectionFields","versionSchema","buildSchemaOptions","disableUnique","draftsEnabled","indexSortableFields","options","minimize","timestamps","compoundIndexes","indexes","sanitizedIndexes","configFields","isVersion","schemaPath","plugin","useEstimatedCount","collectionSlug","versionsFields","versionCollectionName","autoPluralization","dbName","undefined","model","modelName","collectionName","globals","adapter","global","versionGlobalFields","clear"],"mappings":"AAGA,OAAOA,cAAc,WAAU;AAC/B,OAAOC,cAAc,uBAAsB;AAC3C,SACEC,4BAA4B,EAC5BC,2BAA2B,E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CAAChB,OAAO,CAACC,MAAM,CAACe,mBAAmB;wBAC5DC,SAAS;4BACPC,UAAU;4BACVC,YAAY;wBACd;oBACF;oBACAI,cAAciB;oBACdhB,WAAW;oBACXxB,SAAS,IAAI,CAACA,OAAO;oBACrBD;oBACA0B,YAAY,CAAC,OAAO,EAAEc,OAAOhC,IAAI,EAAE;gBACrC;gBAEAK,cAAcc,MAAM,CAAuBzC,UAAU;oBAAE0C,mBAAmB;gBAAK,GAAGD,MAAM,CACtFjC,oBAAoB;oBAClBoC,gBAAgBzC,yBAAyB,IAAI,CAACY,OAAO,CAACC,MAAM,EAAEsC,QAAQ;gBACxE;gBAGF,IAAI,CAAC9B,QAAQ,CAAC8B,OAAOhC,IAAI,CAAC,GAAG,IAAI,CAACX,UAAU,CAACsC,KAAK,CAChDxB,kBACAE,eACAF;YAEJ;QACF;IACF,SAAU;QACRX,mBAAmB0C,KAAK;IAC1B;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrateFresh.d.ts","sourceRoot":"","sources":["../src/migrateFresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAK9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD;;GAEG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,eAAe,EACrB,EACE,kBAA0B,EAC1B,YAAmB,GACpB,EAAE;IAAE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1D,OAAO,CAAC,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"migrateFresh.d.ts","sourceRoot":"","sources":["../src/migrateFresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAK9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD;;GAEG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,eAAe,EACrB,EACE,kBAA0B,EAC1B,YAAmB,GACpB,EAAE;IAAE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1D,OAAO,CAAC,eAAe,CAAC,CAkE1B"}
|