@payloadcms/db-mongodb 3.0.0-canary.867cc07 → 3.0.0-canary.8789b0b
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +12 -3
- package/dist/connect.js.map +1 -1
- package/dist/create.d.ts.map +1 -1
- package/dist/create.js +7 -1
- package/dist/create.js.map +1 -1
- package/dist/createGlobal.d.ts.map +1 -1
- package/dist/createGlobal.js +10 -5
- package/dist/createGlobal.js.map +1 -1
- package/dist/createGlobalVersion.d.ts +1 -1
- package/dist/createGlobalVersion.d.ts.map +1 -1
- package/dist/createGlobalVersion.js +13 -4
- package/dist/createGlobalVersion.js.map +1 -1
- package/dist/createMigration.js +2 -2
- package/dist/createMigration.js.map +1 -1
- package/dist/createVersion.d.ts +1 -1
- package/dist/createVersion.d.ts.map +1 -1
- package/dist/createVersion.js +31 -9
- package/dist/createVersion.js.map +1 -1
- package/dist/deleteOne.js +1 -1
- package/dist/deleteOne.js.map +1 -1
- package/dist/find.d.ts.map +1 -1
- package/dist/find.js +20 -3
- package/dist/find.js.map +1 -1
- package/dist/findGlobal.js +1 -1
- package/dist/findGlobal.js.map +1 -1
- package/dist/findGlobalVersions.d.ts.map +1 -1
- package/dist/findGlobalVersions.js +2 -2
- package/dist/findGlobalVersions.js.map +1 -1
- package/dist/findOne.d.ts.map +1 -1
- package/dist/findOne.js +19 -3
- package/dist/findOne.js.map +1 -1
- package/dist/findVersions.js +1 -1
- package/dist/findVersions.js.map +1 -1
- package/dist/index.d.ts +23 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +9 -6
- package/dist/init.js.map +1 -1
- package/dist/models/buildCollectionSchema.d.ts +1 -2
- package/dist/models/buildCollectionSchema.d.ts.map +1 -1
- package/dist/models/buildCollectionSchema.js +16 -4
- package/dist/models/buildCollectionSchema.js.map +1 -1
- package/dist/models/buildGlobalModel.js +2 -2
- package/dist/models/buildGlobalModel.js.map +1 -1
- package/dist/models/buildSchema.d.ts +1 -2
- package/dist/models/buildSchema.d.ts.map +1 -1
- package/dist/models/buildSchema.js +88 -11
- package/dist/models/buildSchema.js.map +1 -1
- package/dist/queries/buildQuery.d.ts +2 -2
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/buildQuery.js +1 -2
- package/dist/queries/buildQuery.js.map +1 -1
- package/dist/queries/buildSearchParams.d.ts.map +1 -1
- package/dist/queries/buildSearchParams.js +19 -11
- package/dist/queries/buildSearchParams.js.map +1 -1
- package/dist/queries/getLocalizedSortProperty.spec.js +1 -1
- package/dist/queries/getLocalizedSortProperty.spec.js.map +1 -1
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +3 -1
- package/dist/queries/parseParams.js.map +1 -1
- package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
- package/dist/queries/sanitizeQueryValue.js +142 -26
- package/dist/queries/sanitizeQueryValue.js.map +1 -1
- package/dist/queryDrafts.js +1 -1
- package/dist/queryDrafts.js.map +1 -1
- package/dist/transactions/beginTransaction.d.ts.map +1 -1
- package/dist/transactions/beginTransaction.js +2 -0
- package/dist/transactions/beginTransaction.js.map +1 -1
- package/dist/transactions/commitTransaction.d.ts.map +1 -1
- package/dist/transactions/commitTransaction.js +3 -1
- package/dist/transactions/commitTransaction.js.map +1 -1
- package/dist/types.d.ts +7 -4
- 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 +8 -2
- package/dist/updateGlobal.js.map +1 -1
- package/dist/updateGlobalVersion.d.ts +2 -2
- package/dist/updateGlobalVersion.d.ts.map +1 -1
- package/dist/updateGlobalVersion.js +10 -3
- package/dist/updateGlobalVersion.js.map +1 -1
- package/dist/updateOne.d.ts.map +1 -1
- package/dist/updateOne.js +10 -3
- package/dist/updateOne.js.map +1 -1
- package/dist/updateVersion.d.ts +1 -1
- package/dist/updateVersion.d.ts.map +1 -1
- package/dist/updateVersion.js +8 -1
- package/dist/updateVersion.js.map +1 -1
- package/dist/upsert.d.ts +3 -0
- package/dist/upsert.d.ts.map +1 -0
- package/dist/upsert.js +14 -0
- package/dist/upsert.js.map +1 -0
- package/dist/utilities/buildJoinAggregation.d.ts +15 -0
- package/dist/utilities/buildJoinAggregation.d.ts.map +1 -0
- package/dist/utilities/buildJoinAggregation.js +148 -0
- package/dist/utilities/buildJoinAggregation.js.map +1 -0
- package/dist/utilities/getDBName.d.ts.map +1 -1
- package/dist/utilities/getDBName.js +3 -1
- package/dist/utilities/getDBName.js.map +1 -1
- package/dist/utilities/sanitizeInternalFields.d.ts +1 -2
- package/dist/utilities/sanitizeInternalFields.d.ts.map +1 -1
- package/dist/utilities/sanitizeInternalFields.js +1 -2
- package/dist/utilities/sanitizeInternalFields.js.map +1 -1
- package/dist/utilities/sanitizeRelationshipIDs.d.ts +9 -0
- package/dist/utilities/sanitizeRelationshipIDs.d.ts.map +1 -0
- package/dist/utilities/sanitizeRelationshipIDs.js +111 -0
- package/dist/utilities/sanitizeRelationshipIDs.js.map +1 -0
- package/dist/withSession.d.ts +1 -1
- package/dist/withSession.d.ts.map +1 -1
- package/dist/withSession.js +5 -3
- package/dist/withSession.js.map +1 -1
- package/package.json +9 -6
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,EAAE,MAAM,SAAS,CAAA;AAMtC,eAAO,MAAM,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAMtC,eAAO,MAAM,OAAO,EAAE,OA8DrB,CAAA"}
|
package/dist/connect.js
CHANGED
@@ -15,7 +15,9 @@ export const connect = async function connect(options = {
|
|
15
15
|
...this.connectOptions,
|
16
16
|
useFacet: undefined
|
17
17
|
};
|
18
|
-
if (hotReload)
|
18
|
+
if (hotReload) {
|
19
|
+
connectionOptions.autoIndex = false;
|
20
|
+
}
|
19
21
|
try {
|
20
22
|
this.connection = (await mongoose.connect(urlToConnect, connectionOptions)).connection;
|
21
23
|
// If we are running a replica set with MongoDB Memory Server,
|
@@ -35,9 +37,16 @@ export const connect = async function connect(options = {
|
|
35
37
|
this.payload.logger.info('---- DROPPED DATABASE ----');
|
36
38
|
}
|
37
39
|
}
|
40
|
+
if (process.env.NODE_ENV === 'production' && this.prodMigrations) {
|
41
|
+
await this.migrate({
|
42
|
+
migrations: this.prodMigrations
|
43
|
+
});
|
44
|
+
}
|
38
45
|
} catch (err) {
|
39
|
-
|
40
|
-
|
46
|
+
this.payload.logger.error({
|
47
|
+
err,
|
48
|
+
msg: `Error: cannot connect to MongoDB. Details: ${err.message}`
|
49
|
+
});
|
41
50
|
process.exit(1);
|
42
51
|
}
|
43
52
|
};
|
package/dist/connect.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { ConnectOptions } from 'mongoose'\nimport type { Connect } from 'payload'\n\nimport mongoose from 'mongoose'\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: { useFacet: undefined } & ConnectOptions = {\n autoIndex: true,\n ...this.connectOptions,\n useFacet: undefined,\n }\n\n if (hotReload) connectionOptions.autoIndex = false\n\n try {\n this.connection = (await mongoose.connect(urlToConnect, connectionOptions)).connection\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 await new Promise((resolve) => setTimeout(resolve, 2000))\n }\n\n const client = this.connection.getClient()\n\n if (!client.options.replicaSet) {\n this.transactionOptions = false\n this.beginTransaction = undefined\n }\n\n if (!this.mongoMemoryServer && !hotReload) {\n if (process.env.PAYLOAD_DROP_DATABASE === 'true') {\n this.payload.logger.info('---- DROPPING DATABASE ----')\n await mongoose.connection.dropDatabase()\n this.payload.logger.info('---- DROPPED DATABASE ----')\n }\n }\n
|
1
|
+
{"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { ConnectOptions } from 'mongoose'\nimport type { Connect } from 'payload'\n\nimport mongoose from 'mongoose'\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: { useFacet: undefined } & ConnectOptions = {\n autoIndex: true,\n ...this.connectOptions,\n useFacet: undefined,\n }\n\n if (hotReload) {\n connectionOptions.autoIndex = false\n }\n\n try {\n this.connection = (await mongoose.connect(urlToConnect, connectionOptions)).connection\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 await new Promise((resolve) => setTimeout(resolve, 2000))\n }\n\n const client = this.connection.getClient()\n\n if (!client.options.replicaSet) {\n this.transactionOptions = false\n this.beginTransaction = undefined\n }\n\n if (!this.mongoMemoryServer && !hotReload) {\n if (process.env.PAYLOAD_DROP_DATABASE === 'true') {\n this.payload.logger.info('---- DROPPING DATABASE ----')\n await mongoose.connection.dropDatabase()\n this.payload.logger.info('---- DROPPED DATABASE ----')\n }\n }\n\n if (process.env.NODE_ENV === 'production' && this.prodMigrations) {\n await this.migrate({ migrations: this.prodMigrations })\n }\n } catch (err) {\n this.payload.logger.error({\n err,\n msg: `Error: cannot connect to MongoDB. Details: ${err.message}`,\n })\n process.exit(1)\n }\n}\n"],"names":["mongoose","connect","options","hotReload","url","Error","urlToConnect","connectionOptions","autoIndex","connectOptions","useFacet","undefined","connection","mongoMemoryServer","Promise","resolve","setTimeout","client","getClient","replicaSet","transactionOptions","beginTransaction","process","env","PAYLOAD_DROP_DATABASE","payload","logger","info","dropDatabase","NODE_ENV","prodMigrations","migrate","migrations","err","error","msg","message","exit"],"mappings":"AAGA,OAAOA,cAAc,WAAU;AAI/B,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,oBAA8D;QAClEC,WAAW;QACX,GAAG,IAAI,CAACC,cAAc;QACtBC,UAAUC;IACZ;IAEA,IAAIR,WAAW;QACbI,kBAAkBC,SAAS,GAAG;IAChC;IAEA,IAAI;QACF,IAAI,CAACI,UAAU,GAAG,AAAC,CAAA,MAAMZ,SAASC,OAAO,CAACK,cAAcC,kBAAiB,EAAGK,UAAU;QAEtF,8DAA8D;QAC9D,gEAAgE;QAChE,IAAI,IAAI,CAACC,iBAAiB,EAAE;YAC1B,MAAM,IAAIC,QAAQ,CAACC,UAAYC,WAAWD,SAAS;QACrD;QAEA,MAAME,SAAS,IAAI,CAACL,UAAU,CAACM,SAAS;QAExC,IAAI,CAACD,OAAOf,OAAO,CAACiB,UAAU,EAAE;YAC9B,IAAI,CAACC,kBAAkB,GAAG;YAC1B,IAAI,CAACC,gBAAgB,GAAGV;QAC1B;QAEA,IAAI,CAAC,IAAI,CAACE,iBAAiB,IAAI,CAACV,WAAW;YACzC,IAAImB,QAAQC,GAAG,CAACC,qBAAqB,KAAK,QAAQ;gBAChD,IAAI,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC;gBACzB,MAAM3B,SAASY,UAAU,CAACgB,YAAY;gBACtC,IAAI,CAACH,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC;YAC3B;QACF;QAEA,IAAIL,QAAQC,GAAG,CAACM,QAAQ,KAAK,gBAAgB,IAAI,CAACC,cAAc,EAAE;YAChE,MAAM,IAAI,CAACC,OAAO,CAAC;gBAAEC,YAAY,IAAI,CAACF,cAAc;YAAC;QACvD;IACF,EAAE,OAAOG,KAAK;QACZ,IAAI,CAACR,OAAO,CAACC,MAAM,CAACQ,KAAK,CAAC;YACxBD;YACAE,KAAK,CAAC,2CAA2C,EAAEF,IAAIG,OAAO,CAAC,CAAC;QAClE;QACAd,QAAQe,IAAI,CAAC;IACf;AACF,EAAC"}
|
package/dist/create.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAA4B,MAAM,SAAS,CAAA;
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAA4B,MAAM,SAAS,CAAA;AAQ/D,eAAO,MAAM,MAAM,EAAE,MA+BpB,CAAA"}
|
package/dist/create.js
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
import { handleError } from './utilities/handleError.js';
|
2
|
+
import { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js';
|
2
3
|
import { withSession } from './withSession.js';
|
3
4
|
export const create = async function create({ collection, data, req = {} }) {
|
4
5
|
const Model = this.collections[collection];
|
5
6
|
const options = await withSession(this, req);
|
6
7
|
let doc;
|
8
|
+
const sanitizedData = sanitizeRelationshipIDs({
|
9
|
+
config: this.payload.config,
|
10
|
+
data,
|
11
|
+
fields: this.payload.collections[collection].config.fields
|
12
|
+
});
|
7
13
|
try {
|
8
14
|
[doc] = await Model.create([
|
9
|
-
|
15
|
+
sanitizedData
|
10
16
|
], options);
|
11
17
|
} catch (error) {
|
12
18
|
handleError({
|
package/dist/create.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/create.ts"],"sourcesContent":["import type { Create, Document, PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { handleError } from './utilities/handleError.js'\nimport { withSession } from './withSession.js'\n\nexport const create: Create = async function create(\n this: MongooseAdapter,\n { collection, data, req = {} as PayloadRequest },\n) {\n const Model = this.collections[collection]\n const options = await withSession(this, req)\n let doc\n try {\n ;[doc] = await Model.create([
|
1
|
+
{"version":3,"sources":["../src/create.ts"],"sourcesContent":["import type { Create, Document, PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { handleError } from './utilities/handleError.js'\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\nimport { withSession } from './withSession.js'\n\nexport const create: Create = async function create(\n this: MongooseAdapter,\n { collection, data, req = {} as PayloadRequest },\n) {\n const Model = this.collections[collection]\n const options = await withSession(this, req)\n let doc\n\n const sanitizedData = sanitizeRelationshipIDs({\n config: this.payload.config,\n data,\n fields: this.payload.collections[collection].config.fields,\n })\n\n try {\n ;[doc] = await Model.create([sanitizedData], options)\n } catch (error) {\n handleError({ collection, error, req })\n }\n\n // doc.toJSON does not do stuff like converting ObjectIds to string, or date strings to date objects. That's why we use JSON.parse/stringify here\n const result: Document = JSON.parse(JSON.stringify(doc))\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\n return result\n}\n"],"names":["handleError","sanitizeRelationshipIDs","withSession","create","collection","data","req","Model","collections","options","doc","sanitizedData","config","payload","fields","error","result","JSON","parse","stringify","verificationToken","_verificationToken","id","_id"],"mappings":"AAIA,SAASA,WAAW,QAAQ,6BAA4B;AACxD,SAASC,uBAAuB,QAAQ,yCAAwC;AAChF,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,SAAiB,eAAeA,OAE3C,EAAEC,UAAU,EAAEC,IAAI,EAAEC,MAAM,CAAC,CAAmB,EAAE;IAEhD,MAAMC,QAAQ,IAAI,CAACC,WAAW,CAACJ,WAAW;IAC1C,MAAMK,UAAU,MAAMP,YAAY,IAAI,EAAEI;IACxC,IAAII;IAEJ,MAAMC,gBAAgBV,wBAAwB;QAC5CW,QAAQ,IAAI,CAACC,OAAO,CAACD,MAAM;QAC3BP;QACAS,QAAQ,IAAI,CAACD,OAAO,CAACL,WAAW,CAACJ,WAAW,CAACQ,MAAM,CAACE,MAAM;IAC5D;IAEA,IAAI;QACD,CAACJ,IAAI,GAAG,MAAMH,MAAMJ,MAAM,CAAC;YAACQ;SAAc,EAAEF;IAC/C,EAAE,OAAOM,OAAO;QACdf,YAAY;YAAEI;YAAYW;YAAOT;QAAI;IACvC;IAEA,iJAAiJ;IACjJ,MAAMU,SAAmBC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACT;IACnD,MAAMU,oBAAoBV,IAAIW,kBAAkB;IAEhD,uBAAuB;IACvBL,OAAOM,EAAE,GAAGN,OAAOO,GAAG;IACtB,IAAIH,mBAAmB;QACrBJ,OAAOK,kBAAkB,GAAGD;IAC9B;IAEA,OAAOJ;AACT,EAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createGlobal.d.ts","sourceRoot":"","sources":["../src/createGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,SAAS,CAAA;
|
1
|
+
{"version":3,"file":"createGlobal.d.ts","sourceRoot":"","sources":["../src/createGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,SAAS,CAAA;AAQ3D,eAAO,MAAM,YAAY,EAAE,YA0B1B,CAAA"}
|
package/dist/createGlobal.js
CHANGED
@@ -1,11 +1,16 @@
|
|
1
|
-
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js';
|
1
|
+
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js';
|
2
|
+
import { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js';
|
2
3
|
import { withSession } from './withSession.js';
|
3
4
|
export const createGlobal = async function createGlobal({ slug, data, req = {} }) {
|
4
5
|
const Model = this.globals;
|
5
|
-
const global = {
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
const global = sanitizeRelationshipIDs({
|
7
|
+
config: this.payload.config,
|
8
|
+
data: {
|
9
|
+
globalType: slug,
|
10
|
+
...data
|
11
|
+
},
|
12
|
+
fields: this.payload.config.globals.find((globalConfig)=>globalConfig.slug === slug).fields
|
13
|
+
});
|
9
14
|
const options = await withSession(this, req);
|
10
15
|
let [result] = await Model.create([
|
11
16
|
global
|
package/dist/createGlobal.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/createGlobal.ts"],"sourcesContent":["import type { CreateGlobal, PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport sanitizeInternalFields from './utilities/sanitizeInternalFields.js'\nimport { withSession } from './withSession.js'\n\nexport const createGlobal: CreateGlobal = async function createGlobal(\n this: MongooseAdapter,\n { slug, data, req = {} as PayloadRequest },\n) {\n const Model = this.globals\n const global = {\n globalType: slug,\n
|
1
|
+
{"version":3,"sources":["../src/createGlobal.ts"],"sourcesContent":["import type { CreateGlobal, PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\nimport { withSession } from './withSession.js'\n\nexport const createGlobal: CreateGlobal = async function createGlobal(\n this: MongooseAdapter,\n { slug, data, req = {} as PayloadRequest },\n) {\n const Model = this.globals\n\n const global = sanitizeRelationshipIDs({\n config: this.payload.config,\n data: {\n globalType: slug,\n ...data,\n },\n fields: this.payload.config.globals.find((globalConfig) => globalConfig.slug === slug).fields,\n })\n\n const options = await withSession(this, req)\n\n let [result] = (await Model.create([global], options)) as any\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":["sanitizeInternalFields","sanitizeRelationshipIDs","withSession","createGlobal","slug","data","req","Model","globals","global","config","payload","globalType","fields","find","globalConfig","options","result","create","JSON","parse","stringify","id","_id"],"mappings":"AAIA,SAASA,sBAAsB,QAAQ,wCAAuC;AAC9E,SAASC,uBAAuB,QAAQ,yCAAwC;AAChF,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,eAA6B,eAAeA,aAEvD,EAAEC,IAAI,EAAEC,IAAI,EAAEC,MAAM,CAAC,CAAmB,EAAE;IAE1C,MAAMC,QAAQ,IAAI,CAACC,OAAO;IAE1B,MAAMC,SAASR,wBAAwB;QACrCS,QAAQ,IAAI,CAACC,OAAO,CAACD,MAAM;QAC3BL,MAAM;YACJO,YAAYR;YACZ,GAAGC,IAAI;QACT;QACAQ,QAAQ,IAAI,CAACF,OAAO,CAACD,MAAM,CAACF,OAAO,CAACM,IAAI,CAAC,CAACC,eAAiBA,aAAaX,IAAI,KAAKA,MAAMS,MAAM;IAC/F;IAEA,MAAMG,UAAU,MAAMd,YAAY,IAAI,EAAEI;IAExC,IAAI,CAACW,OAAO,GAAI,MAAMV,MAAMW,MAAM,CAAC;QAACT;KAAO,EAAEO;IAE7CC,SAASE,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACJ;IAEnC,uBAAuB;IACvBA,OAAOK,EAAE,GAAGL,OAAOM,GAAG;IACtBN,SAASjB,uBAAuBiB;IAEhC,OAAOA;AACT,EAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createGlobalVersion.d.ts","sourceRoot":"","sources":["../src/createGlobalVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
1
|
+
{"version":3,"file":"createGlobalVersion.d.ts","sourceRoot":"","sources":["../src/createGlobalVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EAGzB,MAAM,SAAS,CAAA;AAOhB,eAAO,MAAM,mBAAmB,EAAE,mBAsEjC,CAAA"}
|
@@ -1,16 +1,25 @@
|
|
1
|
+
import { buildVersionGlobalFields } from 'payload';
|
2
|
+
import { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js';
|
1
3
|
import { withSession } from './withSession.js';
|
2
|
-
export const createGlobalVersion = async function createGlobalVersion({ autosave, createdAt, globalSlug, parent, req = {}, updatedAt, versionData }) {
|
4
|
+
export const createGlobalVersion = async function createGlobalVersion({ autosave, createdAt, globalSlug, parent, publishedLocale, req = {}, snapshot, updatedAt, versionData }) {
|
3
5
|
const VersionModel = this.versions[globalSlug];
|
4
6
|
const options = await withSession(this, req);
|
5
|
-
const
|
6
|
-
|
7
|
+
const data = sanitizeRelationshipIDs({
|
8
|
+
config: this.payload.config,
|
9
|
+
data: {
|
7
10
|
autosave,
|
8
11
|
createdAt,
|
9
12
|
latest: true,
|
10
13
|
parent,
|
14
|
+
publishedLocale,
|
15
|
+
snapshot,
|
11
16
|
updatedAt,
|
12
17
|
version: versionData
|
13
|
-
}
|
18
|
+
},
|
19
|
+
fields: buildVersionGlobalFields(this.payload.config, this.payload.config.globals.find((global)=>global.slug === globalSlug))
|
20
|
+
});
|
21
|
+
const [doc] = await VersionModel.create([
|
22
|
+
data
|
14
23
|
], options, req);
|
15
24
|
await VersionModel.updateMany({
|
16
25
|
$and: [
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/createGlobalVersion.ts"],"sourcesContent":["import type
|
1
|
+
{"version":3,"sources":["../src/createGlobalVersion.ts"],"sourcesContent":["import {\n buildVersionGlobalFields,\n type CreateGlobalVersion,\n type Document,\n type PayloadRequest,\n} from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\nimport { withSession } from './withSession.js'\n\nexport const createGlobalVersion: CreateGlobalVersion = async function createGlobalVersion(\n this: MongooseAdapter,\n {\n autosave,\n createdAt,\n globalSlug,\n parent,\n publishedLocale,\n req = {} as PayloadRequest,\n snapshot,\n updatedAt,\n versionData,\n },\n) {\n const VersionModel = this.versions[globalSlug]\n const options = await withSession(this, req)\n\n const data = sanitizeRelationshipIDs({\n config: this.payload.config,\n data: {\n autosave,\n createdAt,\n latest: true,\n parent,\n publishedLocale,\n snapshot,\n updatedAt,\n version: versionData,\n },\n fields: buildVersionGlobalFields(\n this.payload.config,\n this.payload.config.globals.find((global) => global.slug === globalSlug),\n ),\n })\n\n const [doc] = await VersionModel.create([data], options, req)\n\n await VersionModel.updateMany(\n {\n $and: [\n {\n _id: {\n $ne: doc._id,\n },\n },\n {\n parent: {\n $eq: parent,\n },\n },\n {\n latest: {\n $eq: true,\n },\n },\n ],\n },\n { $unset: { latest: 1 } },\n options,\n )\n\n const result: Document = JSON.parse(JSON.stringify(doc))\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","sanitizeRelationshipIDs","withSession","createGlobalVersion","autosave","createdAt","globalSlug","parent","publishedLocale","req","snapshot","updatedAt","versionData","VersionModel","versions","options","data","config","payload","latest","version","fields","globals","find","global","slug","doc","create","updateMany","$and","_id","$ne","$eq","$unset","result","JSON","parse","stringify","verificationToken","_verificationToken","id"],"mappings":"AAAA,SACEA,wBAAwB,QAInB,UAAS;AAIhB,SAASC,uBAAuB,QAAQ,yCAAwC;AAChF,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,sBAA2C,eAAeA,oBAErE,EACEC,QAAQ,EACRC,SAAS,EACTC,UAAU,EACVC,MAAM,EACNC,eAAe,EACfC,MAAM,CAAC,CAAmB,EAC1BC,QAAQ,EACRC,SAAS,EACTC,WAAW,EACZ;IAED,MAAMC,eAAe,IAAI,CAACC,QAAQ,CAACR,WAAW;IAC9C,MAAMS,UAAU,MAAMb,YAAY,IAAI,EAAEO;IAExC,MAAMO,OAAOf,wBAAwB;QACnCgB,QAAQ,IAAI,CAACC,OAAO,CAACD,MAAM;QAC3BD,MAAM;YACJZ;YACAC;YACAc,QAAQ;YACRZ;YACAC;YACAE;YACAC;YACAS,SAASR;QACX;QACAS,QAAQrB,yBACN,IAAI,CAACkB,OAAO,CAACD,MAAM,EACnB,IAAI,CAACC,OAAO,CAACD,MAAM,CAACK,OAAO,CAACC,IAAI,CAAC,CAACC,SAAWA,OAAOC,IAAI,KAAKnB;IAEjE;IAEA,MAAM,CAACoB,IAAI,GAAG,MAAMb,aAAac,MAAM,CAAC;QAACX;KAAK,EAAED,SAASN;IAEzD,MAAMI,aAAae,UAAU,CAC3B;QACEC,MAAM;YACJ;gBACEC,KAAK;oBACHC,KAAKL,IAAII,GAAG;gBACd;YACF;YACA;gBACEvB,QAAQ;oBACNyB,KAAKzB;gBACP;YACF;YACA;gBACEY,QAAQ;oBACNa,KAAK;gBACP;YACF;SACD;IACH,GACA;QAAEC,QAAQ;YAAEd,QAAQ;QAAE;IAAE,GACxBJ;IAGF,MAAMmB,SAAmBC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACX;IACnD,MAAMY,oBAAoBZ,IAAIa,kBAAkB;IAEhD,uBAAuB;IACvBL,OAAOM,EAAE,GAAGN,OAAOJ,GAAG;IACtB,IAAIQ,mBAAmB;QACrBJ,OAAOK,kBAAkB,GAAGD;IAC9B;IACA,OAAOJ;AACT,EAAC"}
|
package/dist/createMigration.js
CHANGED
@@ -8,11 +8,11 @@ const migrationTemplate = ({ downSQL, imports, upSQL })=>`import {
|
|
8
8
|
} from '@payloadcms/db-mongodb'
|
9
9
|
${imports}
|
10
10
|
|
11
|
-
export async function up({ payload }: MigrateUpArgs): Promise<void> {
|
11
|
+
export async function up({ payload, req }: MigrateUpArgs): Promise<void> {
|
12
12
|
${upSQL ?? ` // Migration code`}
|
13
13
|
}
|
14
14
|
|
15
|
-
export async function down({ payload }: MigrateDownArgs): Promise<void> {
|
15
|
+
export async function down({ payload, req }: MigrateDownArgs): Promise<void> {
|
16
16
|
${downSQL ?? ` // Migration code`}
|
17
17
|
}
|
18
18
|
`;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/createMigration.ts"],"sourcesContent":["import type { CreateMigration, MigrationTemplateArgs } from 'payload'\n\nimport fs from 'fs'\nimport path from 'path'\nimport { getPredefinedMigration } from 'payload'\nimport { fileURLToPath } from 'url'\n\nconst migrationTemplate = ({ downSQL, imports, upSQL }: MigrationTemplateArgs): string => `import {\n MigrateUpArgs,\n MigrateDownArgs,\n} from '@payloadcms/db-mongodb'\n${imports}\n\nexport async function up({ payload }: MigrateUpArgs): Promise<void> {\n${upSQL ?? ` // Migration code`}\n}\n\nexport async function down({ payload }: MigrateDownArgs): Promise<void> {\n${downSQL ?? ` // Migration code`}\n}\n`\n\nexport const createMigration: CreateMigration = async function createMigration({\n file,\n migrationName,\n payload,\n}) {\n const filename = fileURLToPath(import.meta.url)\n const dirname = path.dirname(filename)\n\n const dir = payload.db.migrationDir\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir)\n }\n const predefinedMigration = await getPredefinedMigration({\n dirname,\n file,\n migrationName,\n payload,\n })\n\n const migrationFileContent = migrationTemplate(predefinedMigration)\n\n const [yyymmdd, hhmmss] = new Date().toISOString().split('T')\n const formattedDate = yyymmdd.replace(/\\D/g, '')\n const formattedTime = hhmmss.split('.')[0].replace(/\\D/g, '')\n\n const timestamp = `${formattedDate}_${formattedTime}`\n\n const formattedName = migrationName?.replace(/\\W/g, '_')\n const fileName = migrationName ? `${timestamp}_${formattedName}.ts` : `${timestamp}_migration.ts`\n const filePath = `${dir}/${fileName}`\n fs.writeFileSync(filePath, migrationFileContent)\n payload.logger.info({ msg: `Migration created at ${filePath}` })\n}\n"],"names":["fs","path","getPredefinedMigration","fileURLToPath","migrationTemplate","downSQL","imports","upSQL","createMigration","file","migrationName","payload","filename","url","dirname","dir","db","migrationDir","existsSync","mkdirSync","predefinedMigration","migrationFileContent","yyymmdd","hhmmss","Date","toISOString","split","formattedDate","replace","formattedTime","timestamp","formattedName","fileName","filePath","writeFileSync","logger","info","msg"],"mappings":"AAEA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AACvB,SAASC,sBAAsB,QAAQ,UAAS;AAChD,SAASC,aAAa,QAAQ,MAAK;AAEnC,MAAMC,oBAAoB,CAAC,EAAEC,OAAO,EAAEC,OAAO,EAAEC,KAAK,EAAyB,GAAa,CAAC;;;;AAI3F,EAAED,QAAQ;;;AAGV,EAAEC,SAAS,CAAC,mBAAmB,CAAC,CAAC;;;;AAIjC,EAAEF,WAAW,CAAC,mBAAmB,CAAC,CAAC;;AAEnC,CAAC;AAED,OAAO,MAAMG,kBAAmC,eAAeA,gBAAgB,EAC7EC,IAAI,EACJC,aAAa,EACbC,OAAO,EACR;IACC,MAAMC,WAAWT,cAAc,YAAYU,GAAG;IAC9C,MAAMC,UAAUb,KAAKa,OAAO,CAACF;IAE7B,MAAMG,MAAMJ,QAAQK,EAAE,CAACC,YAAY;IACnC,IAAI,CAACjB,GAAGkB,UAAU,CAACH,MAAM;QACvBf,GAAGmB,SAAS,CAACJ;IACf;IACA,MAAMK,sBAAsB,MAAMlB,uBAAuB;QACvDY;QACAL;QACAC;QACAC;IACF;IAEA,MAAMU,uBAAuBjB,kBAAkBgB;IAE/C,MAAM,CAACE,SAASC,OAAO,GAAG,IAAIC,OAAOC,WAAW,GAAGC,KAAK,CAAC;IACzD,MAAMC,gBAAgBL,QAAQM,OAAO,CAAC,OAAO;IAC7C,MAAMC,gBAAgBN,OAAOG,KAAK,CAAC,IAAI,CAAC,EAAE,CAACE,OAAO,CAAC,OAAO;IAE1D,MAAME,YAAY,CAAC,EAAEH,cAAc,CAAC,EAAEE,cAAc,CAAC;IAErD,MAAME,gBAAgBrB,eAAekB,QAAQ,OAAO;IACpD,MAAMI,WAAWtB,gBAAgB,CAAC,EAAEoB,UAAU,CAAC,EAAEC,cAAc,GAAG,CAAC,GAAG,CAAC,EAAED,UAAU,aAAa,CAAC;IACjG,MAAMG,WAAW,CAAC,EAAElB,IAAI,CAAC,EAAEiB,SAAS,CAAC;IACrChC,GAAGkC,aAAa,CAACD,UAAUZ;IAC3BV,QAAQwB,MAAM,CAACC,IAAI,CAAC;QAAEC,KAAK,CAAC,qBAAqB,EAAEJ,SAAS,CAAC;IAAC;AAChE,EAAC"}
|
1
|
+
{"version":3,"sources":["../src/createMigration.ts"],"sourcesContent":["import type { CreateMigration, MigrationTemplateArgs } from 'payload'\n\nimport fs from 'fs'\nimport path from 'path'\nimport { getPredefinedMigration } from 'payload'\nimport { fileURLToPath } from 'url'\n\nconst migrationTemplate = ({ downSQL, imports, upSQL }: MigrationTemplateArgs): string => `import {\n MigrateUpArgs,\n MigrateDownArgs,\n} from '@payloadcms/db-mongodb'\n${imports}\n\nexport async function up({ payload, req }: MigrateUpArgs): Promise<void> {\n${upSQL ?? ` // Migration code`}\n}\n\nexport async function down({ payload, req }: MigrateDownArgs): Promise<void> {\n${downSQL ?? ` // Migration code`}\n}\n`\n\nexport const createMigration: CreateMigration = async function createMigration({\n file,\n migrationName,\n payload,\n}) {\n const filename = fileURLToPath(import.meta.url)\n const dirname = path.dirname(filename)\n\n const dir = payload.db.migrationDir\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir)\n }\n const predefinedMigration = await getPredefinedMigration({\n dirname,\n file,\n migrationName,\n payload,\n })\n\n const migrationFileContent = migrationTemplate(predefinedMigration)\n\n const [yyymmdd, hhmmss] = new Date().toISOString().split('T')\n const formattedDate = yyymmdd.replace(/\\D/g, '')\n const formattedTime = hhmmss.split('.')[0].replace(/\\D/g, '')\n\n const timestamp = `${formattedDate}_${formattedTime}`\n\n const formattedName = migrationName?.replace(/\\W/g, '_')\n const fileName = migrationName ? `${timestamp}_${formattedName}.ts` : `${timestamp}_migration.ts`\n const filePath = `${dir}/${fileName}`\n fs.writeFileSync(filePath, migrationFileContent)\n payload.logger.info({ msg: `Migration created at ${filePath}` })\n}\n"],"names":["fs","path","getPredefinedMigration","fileURLToPath","migrationTemplate","downSQL","imports","upSQL","createMigration","file","migrationName","payload","filename","url","dirname","dir","db","migrationDir","existsSync","mkdirSync","predefinedMigration","migrationFileContent","yyymmdd","hhmmss","Date","toISOString","split","formattedDate","replace","formattedTime","timestamp","formattedName","fileName","filePath","writeFileSync","logger","info","msg"],"mappings":"AAEA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AACvB,SAASC,sBAAsB,QAAQ,UAAS;AAChD,SAASC,aAAa,QAAQ,MAAK;AAEnC,MAAMC,oBAAoB,CAAC,EAAEC,OAAO,EAAEC,OAAO,EAAEC,KAAK,EAAyB,GAAa,CAAC;;;;AAI3F,EAAED,QAAQ;;;AAGV,EAAEC,SAAS,CAAC,mBAAmB,CAAC,CAAC;;;;AAIjC,EAAEF,WAAW,CAAC,mBAAmB,CAAC,CAAC;;AAEnC,CAAC;AAED,OAAO,MAAMG,kBAAmC,eAAeA,gBAAgB,EAC7EC,IAAI,EACJC,aAAa,EACbC,OAAO,EACR;IACC,MAAMC,WAAWT,cAAc,YAAYU,GAAG;IAC9C,MAAMC,UAAUb,KAAKa,OAAO,CAACF;IAE7B,MAAMG,MAAMJ,QAAQK,EAAE,CAACC,YAAY;IACnC,IAAI,CAACjB,GAAGkB,UAAU,CAACH,MAAM;QACvBf,GAAGmB,SAAS,CAACJ;IACf;IACA,MAAMK,sBAAsB,MAAMlB,uBAAuB;QACvDY;QACAL;QACAC;QACAC;IACF;IAEA,MAAMU,uBAAuBjB,kBAAkBgB;IAE/C,MAAM,CAACE,SAASC,OAAO,GAAG,IAAIC,OAAOC,WAAW,GAAGC,KAAK,CAAC;IACzD,MAAMC,gBAAgBL,QAAQM,OAAO,CAAC,OAAO;IAC7C,MAAMC,gBAAgBN,OAAOG,KAAK,CAAC,IAAI,CAAC,EAAE,CAACE,OAAO,CAAC,OAAO;IAE1D,MAAME,YAAY,CAAC,EAAEH,cAAc,CAAC,EAAEE,cAAc,CAAC;IAErD,MAAME,gBAAgBrB,eAAekB,QAAQ,OAAO;IACpD,MAAMI,WAAWtB,gBAAgB,CAAC,EAAEoB,UAAU,CAAC,EAAEC,cAAc,GAAG,CAAC,GAAG,CAAC,EAAED,UAAU,aAAa,CAAC;IACjG,MAAMG,WAAW,CAAC,EAAElB,IAAI,CAAC,EAAEiB,SAAS,CAAC;IACrChC,GAAGkC,aAAa,CAACD,UAAUZ;IAC3BV,QAAQwB,MAAM,CAACC,IAAI,CAAC;QAAEC,KAAK,CAAC,qBAAqB,EAAEJ,SAAS,CAAC;IAAC;AAChE,EAAC"}
|
package/dist/createVersion.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createVersion.d.ts","sourceRoot":"","sources":["../src/createVersion.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"createVersion.d.ts","sourceRoot":"","sources":["../src/createVersion.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,SAAS,CAAA;AAOhB,eAAO,MAAM,aAAa,EAAE,aAmF3B,CAAA"}
|
package/dist/createVersion.js
CHANGED
@@ -1,17 +1,43 @@
|
|
1
|
+
import mongoose from 'mongoose';
|
2
|
+
import { buildVersionCollectionFields } from 'payload';
|
3
|
+
import { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js';
|
1
4
|
import { withSession } from './withSession.js';
|
2
|
-
export const createVersion = async function createVersion({ autosave, collectionSlug, createdAt, parent, req = {}, updatedAt, versionData }) {
|
5
|
+
export const createVersion = async function createVersion({ autosave, collectionSlug, createdAt, parent, publishedLocale, req = {}, snapshot, updatedAt, versionData }) {
|
3
6
|
const VersionModel = this.versions[collectionSlug];
|
4
7
|
const options = await withSession(this, req);
|
5
|
-
const
|
6
|
-
|
8
|
+
const data = sanitizeRelationshipIDs({
|
9
|
+
config: this.payload.config,
|
10
|
+
data: {
|
7
11
|
autosave,
|
8
12
|
createdAt,
|
9
13
|
latest: true,
|
10
14
|
parent,
|
15
|
+
publishedLocale,
|
16
|
+
snapshot,
|
11
17
|
updatedAt,
|
12
18
|
version: versionData
|
13
|
-
}
|
19
|
+
},
|
20
|
+
fields: buildVersionCollectionFields(this.payload.config, this.payload.collections[collectionSlug].config)
|
21
|
+
});
|
22
|
+
const [doc] = await VersionModel.create([
|
23
|
+
data
|
14
24
|
], options, req);
|
25
|
+
const parentQuery = {
|
26
|
+
$or: [
|
27
|
+
{
|
28
|
+
parent: {
|
29
|
+
$eq: data.parent
|
30
|
+
}
|
31
|
+
}
|
32
|
+
]
|
33
|
+
};
|
34
|
+
if (data.parent instanceof mongoose.Types.ObjectId) {
|
35
|
+
parentQuery.$or.push({
|
36
|
+
parent: {
|
37
|
+
$eq: data.parent.toString()
|
38
|
+
}
|
39
|
+
});
|
40
|
+
}
|
15
41
|
await VersionModel.updateMany({
|
16
42
|
$and: [
|
17
43
|
{
|
@@ -19,11 +45,7 @@ export const createVersion = async function createVersion({ autosave, collection
|
|
19
45
|
$ne: doc._id
|
20
46
|
}
|
21
47
|
},
|
22
|
-
|
23
|
-
parent: {
|
24
|
-
$eq: parent
|
25
|
-
}
|
26
|
-
},
|
48
|
+
parentQuery,
|
27
49
|
{
|
28
50
|
latest: {
|
29
51
|
$eq: true
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/createVersion.ts"],"sourcesContent":["import
|
1
|
+
{"version":3,"sources":["../src/createVersion.ts"],"sourcesContent":["import mongoose from 'mongoose'\nimport {\n buildVersionCollectionFields,\n type CreateVersion,\n type Document,\n type PayloadRequest,\n} from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\nimport { withSession } from './withSession.js'\n\nexport const createVersion: CreateVersion = async function createVersion(\n this: MongooseAdapter,\n {\n autosave,\n collectionSlug,\n createdAt,\n parent,\n publishedLocale,\n req = {} as PayloadRequest,\n snapshot,\n updatedAt,\n versionData,\n },\n) {\n const VersionModel = this.versions[collectionSlug]\n const options = await withSession(this, req)\n\n const data = sanitizeRelationshipIDs({\n config: this.payload.config,\n data: {\n autosave,\n createdAt,\n latest: true,\n parent,\n publishedLocale,\n snapshot,\n updatedAt,\n version: versionData,\n },\n fields: buildVersionCollectionFields(\n this.payload.config,\n this.payload.collections[collectionSlug].config,\n ),\n })\n\n const [doc] = await VersionModel.create([data], options, req)\n\n const parentQuery = {\n $or: [\n {\n parent: {\n $eq: data.parent,\n },\n },\n ],\n }\n if (data.parent instanceof mongoose.Types.ObjectId) {\n parentQuery.$or.push({\n parent: {\n $eq: data.parent.toString(),\n },\n })\n }\n\n await VersionModel.updateMany(\n {\n $and: [\n {\n _id: {\n $ne: doc._id,\n },\n },\n parentQuery,\n {\n latest: {\n $eq: true,\n },\n },\n ],\n },\n { $unset: { latest: 1 } },\n options,\n )\n\n const result: Document = JSON.parse(JSON.stringify(doc))\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":["mongoose","buildVersionCollectionFields","sanitizeRelationshipIDs","withSession","createVersion","autosave","collectionSlug","createdAt","parent","publishedLocale","req","snapshot","updatedAt","versionData","VersionModel","versions","options","data","config","payload","latest","version","fields","collections","doc","create","parentQuery","$or","$eq","Types","ObjectId","push","toString","updateMany","$and","_id","$ne","$unset","result","JSON","parse","stringify","verificationToken","_verificationToken","id"],"mappings":"AAAA,OAAOA,cAAc,WAAU;AAC/B,SACEC,4BAA4B,QAIvB,UAAS;AAIhB,SAASC,uBAAuB,QAAQ,yCAAwC;AAChF,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,gBAA+B,eAAeA,cAEzD,EACEC,QAAQ,EACRC,cAAc,EACdC,SAAS,EACTC,MAAM,EACNC,eAAe,EACfC,MAAM,CAAC,CAAmB,EAC1BC,QAAQ,EACRC,SAAS,EACTC,WAAW,EACZ;IAED,MAAMC,eAAe,IAAI,CAACC,QAAQ,CAACT,eAAe;IAClD,MAAMU,UAAU,MAAMb,YAAY,IAAI,EAAEO;IAExC,MAAMO,OAAOf,wBAAwB;QACnCgB,QAAQ,IAAI,CAACC,OAAO,CAACD,MAAM;QAC3BD,MAAM;YACJZ;YACAE;YACAa,QAAQ;YACRZ;YACAC;YACAE;YACAC;YACAS,SAASR;QACX;QACAS,QAAQrB,6BACN,IAAI,CAACkB,OAAO,CAACD,MAAM,EACnB,IAAI,CAACC,OAAO,CAACI,WAAW,CAACjB,eAAe,CAACY,MAAM;IAEnD;IAEA,MAAM,CAACM,IAAI,GAAG,MAAMV,aAAaW,MAAM,CAAC;QAACR;KAAK,EAAED,SAASN;IAEzD,MAAMgB,cAAc;QAClBC,KAAK;YACH;gBACEnB,QAAQ;oBACNoB,KAAKX,KAAKT,MAAM;gBAClB;YACF;SACD;IACH;IACA,IAAIS,KAAKT,MAAM,YAAYR,SAAS6B,KAAK,CAACC,QAAQ,EAAE;QAClDJ,YAAYC,GAAG,CAACI,IAAI,CAAC;YACnBvB,QAAQ;gBACNoB,KAAKX,KAAKT,MAAM,CAACwB,QAAQ;YAC3B;QACF;IACF;IAEA,MAAMlB,aAAamB,UAAU,CAC3B;QACEC,MAAM;YACJ;gBACEC,KAAK;oBACHC,KAAKZ,IAAIW,GAAG;gBACd;YACF;YACAT;YACA;gBACEN,QAAQ;oBACNQ,KAAK;gBACP;YACF;SACD;IACH,GACA;QAAES,QAAQ;YAAEjB,QAAQ;QAAE;IAAE,GACxBJ;IAGF,MAAMsB,SAAmBC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACjB;IACnD,MAAMkB,oBAAoBlB,IAAImB,kBAAkB;IAEhD,uBAAuB;IACvBL,OAAOM,EAAE,GAAGN,OAAOH,GAAG;IACtB,IAAIO,mBAAmB;QACrBJ,OAAOK,kBAAkB,GAAGD;IAC9B;IACA,OAAOJ;AACT,EAAC"}
|
package/dist/deleteOne.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js';
|
1
|
+
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js';
|
2
2
|
import { withSession } from './withSession.js';
|
3
3
|
export const deleteOne = async function deleteOne({ collection, req = {}, where }) {
|
4
4
|
const Model = this.collections[collection];
|
package/dist/deleteOne.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/deleteOne.ts"],"sourcesContent":["import type { DeleteOne, Document, PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport sanitizeInternalFields from './utilities/sanitizeInternalFields.js'\nimport { withSession } from './withSession.js'\n\nexport const deleteOne: DeleteOne = async function deleteOne(\n this: MongooseAdapter,\n { collection, req = {} as PayloadRequest, where },\n) {\n const Model = this.collections[collection]\n const options = await withSession(this, req)\n\n const query = await Model.buildQuery({\n payload: this.payload,\n where,\n })\n\n const doc = await Model.findOneAndDelete(query, options).lean()\n\n let result: Document = JSON.parse(JSON.stringify(doc))\n\n // custom id type reset\n result.id = result._id\n result = sanitizeInternalFields(result)\n\n return result\n}\n"],"names":["sanitizeInternalFields","withSession","deleteOne","collection","req","where","Model","collections","options","query","buildQuery","payload","doc","findOneAndDelete","lean","result","JSON","parse","stringify","id","_id"],"mappings":"AAIA,
|
1
|
+
{"version":3,"sources":["../src/deleteOne.ts"],"sourcesContent":["import type { DeleteOne, Document, PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\nimport { withSession } from './withSession.js'\n\nexport const deleteOne: DeleteOne = async function deleteOne(\n this: MongooseAdapter,\n { collection, req = {} as PayloadRequest, where },\n) {\n const Model = this.collections[collection]\n const options = await withSession(this, req)\n\n const query = await Model.buildQuery({\n payload: this.payload,\n where,\n })\n\n const doc = await Model.findOneAndDelete(query, options).lean()\n\n let result: Document = JSON.parse(JSON.stringify(doc))\n\n // custom id type reset\n result.id = result._id\n result = sanitizeInternalFields(result)\n\n return result\n}\n"],"names":["sanitizeInternalFields","withSession","deleteOne","collection","req","where","Model","collections","options","query","buildQuery","payload","doc","findOneAndDelete","lean","result","JSON","parse","stringify","id","_id"],"mappings":"AAIA,SAASA,sBAAsB,QAAQ,wCAAuC;AAC9E,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,YAAuB,eAAeA,UAEjD,EAAEC,UAAU,EAAEC,MAAM,CAAC,CAAmB,EAAEC,KAAK,EAAE;IAEjD,MAAMC,QAAQ,IAAI,CAACC,WAAW,CAACJ,WAAW;IAC1C,MAAMK,UAAU,MAAMP,YAAY,IAAI,EAAEG;IAExC,MAAMK,QAAQ,MAAMH,MAAMI,UAAU,CAAC;QACnCC,SAAS,IAAI,CAACA,OAAO;QACrBN;IACF;IAEA,MAAMO,MAAM,MAAMN,MAAMO,gBAAgB,CAACJ,OAAOD,SAASM,IAAI;IAE7D,IAAIC,SAAmBC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACN;IAEjD,uBAAuB;IACvBG,OAAOI,EAAE,GAAGJ,OAAOK,GAAG;IACtBL,SAASf,uBAAuBe;IAEhC,OAAOA;AACT,EAAC"}
|
package/dist/find.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../src/find.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAkB,MAAM,SAAS,CAAA;
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../src/find.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAkB,MAAM,SAAS,CAAA;AAWnD,eAAO,MAAM,IAAI,EAAE,IAsHlB,CAAA"}
|
package/dist/find.js
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
import { flattenWhereToOperators } from 'payload';
|
2
2
|
import { buildSortParam } from './queries/buildSortParam.js';
|
3
|
-
import
|
3
|
+
import { buildJoinAggregation } from './utilities/buildJoinAggregation.js';
|
4
|
+
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js';
|
4
5
|
import { withSession } from './withSession.js';
|
5
|
-
export const find = async function find({ collection, limit, locale, page, pagination, req = {}, sort: sortArg, where }) {
|
6
|
+
export const find = async function find({ collection, joins = {}, limit = 0, locale, page, pagination, projection, req = {}, sort: sortArg, where }) {
|
6
7
|
const Model = this.collections[collection];
|
7
8
|
const collectionConfig = this.payload.collections[collection].config;
|
8
9
|
const options = await withSession(this, req);
|
@@ -35,6 +36,7 @@ export const find = async function find({ collection, limit, locale, page, pagin
|
|
35
36
|
options,
|
36
37
|
page,
|
37
38
|
pagination,
|
39
|
+
projection,
|
38
40
|
sort,
|
39
41
|
useEstimatedCount
|
40
42
|
};
|
@@ -68,7 +70,22 @@ export const find = async function find({ collection, limit, locale, page, pagin
|
|
68
70
|
paginationOptions.pagination = false;
|
69
71
|
}
|
70
72
|
}
|
71
|
-
|
73
|
+
let result;
|
74
|
+
const aggregate = await buildJoinAggregation({
|
75
|
+
adapter: this,
|
76
|
+
collection,
|
77
|
+
collectionConfig,
|
78
|
+
joins,
|
79
|
+
limit,
|
80
|
+
locale,
|
81
|
+
query
|
82
|
+
});
|
83
|
+
// build join aggregation
|
84
|
+
if (aggregate) {
|
85
|
+
result = await Model.aggregatePaginate(Model.aggregate(aggregate), paginationOptions);
|
86
|
+
} else {
|
87
|
+
result = await Model.paginate(query, paginationOptions);
|
88
|
+
}
|
72
89
|
const docs = JSON.parse(JSON.stringify(result.docs));
|
73
90
|
return {
|
74
91
|
...result,
|
package/dist/find.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/find.ts"],"sourcesContent":["import type { PaginateOptions } from 'mongoose'\nimport type { Find, PayloadRequest } from 'payload'\n\nimport { flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport sanitizeInternalFields from './utilities/sanitizeInternalFields.js'\nimport { withSession } from './withSession.js'\n\nexport const find: Find = async function find(\n this: MongooseAdapter,\n {
|
1
|
+
{"version":3,"sources":["../src/find.ts"],"sourcesContent":["import type { PaginateOptions } from 'mongoose'\nimport type { Find, PayloadRequest } from 'payload'\n\nimport { flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { buildJoinAggregation } from './utilities/buildJoinAggregation.js'\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\nimport { withSession } from './withSession.js'\n\nexport const find: Find = async function find(\n this: MongooseAdapter,\n {\n collection,\n joins = {},\n limit = 0,\n locale,\n page,\n pagination,\n projection,\n req = {} as PayloadRequest,\n sort: sortArg,\n where,\n },\n) {\n const Model = this.collections[collection]\n const collectionConfig = this.payload.collections[collection].config\n const options = await withSession(this, req)\n\n let hasNearConstraint = false\n\n if (where) {\n const constraints = flattenWhereToOperators(where)\n hasNearConstraint = constraints.some((prop) => Object.keys(prop).some((key) => key === 'near'))\n }\n\n let sort\n if (!hasNearConstraint) {\n sort = buildSortParam({\n config: this.payload.config,\n fields: collectionConfig.fields,\n locale,\n sort: sortArg || collectionConfig.defaultSort,\n timestamps: true,\n })\n }\n\n const query = await Model.buildQuery({\n locale,\n payload: this.payload,\n where,\n })\n\n // useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.\n const useEstimatedCount = hasNearConstraint || !query || Object.keys(query).length === 0\n const paginationOptions: PaginateOptions = {\n forceCountFn: hasNearConstraint,\n lean: true,\n leanWithId: true,\n options,\n page,\n pagination,\n projection,\n sort,\n useEstimatedCount,\n }\n\n if (this.collation) {\n const defaultLocale = 'en'\n paginationOptions.collation = {\n locale: locale && locale !== 'all' && locale !== '*' ? locale : defaultLocale,\n ...this.collation,\n }\n }\n\n if (!useEstimatedCount && Object.keys(query).length === 0 && this.disableIndexHints !== true) {\n // Improve the performance of the countDocuments query which is used if useEstimatedCount is set to false by adding\n // a hint. By default, if no hint is provided, MongoDB does not use an indexed field to count the returned documents,\n // which makes queries very slow. This only happens when no query (filter) is provided. If one is provided, it uses\n // the correct indexed field\n paginationOptions.useCustomCountFn = () => {\n return Promise.resolve(\n Model.countDocuments(query, {\n ...options,\n hint: { _id: 1 },\n }),\n )\n }\n }\n\n if (limit >= 0) {\n paginationOptions.limit = limit\n // limit must also be set here, it's ignored when pagination is false\n paginationOptions.options.limit = limit\n\n // Disable pagination if limit is 0\n if (limit === 0) {\n paginationOptions.pagination = false\n }\n }\n\n let result\n\n const aggregate = await buildJoinAggregation({\n adapter: this,\n collection,\n collectionConfig,\n joins,\n limit,\n locale,\n query,\n })\n // build join aggregation\n if (aggregate) {\n result = await Model.aggregatePaginate(Model.aggregate(aggregate), paginationOptions)\n } else {\n result = await Model.paginate(query, paginationOptions)\n }\n\n const docs = JSON.parse(JSON.stringify(result.docs))\n\n return {\n ...result,\n docs: docs.map((doc) => {\n doc.id = doc._id\n return sanitizeInternalFields(doc)\n }),\n }\n}\n"],"names":["flattenWhereToOperators","buildSortParam","buildJoinAggregation","sanitizeInternalFields","withSession","find","collection","joins","limit","locale","page","pagination","projection","req","sort","sortArg","where","Model","collections","collectionConfig","payload","config","options","hasNearConstraint","constraints","some","prop","Object","keys","key","fields","defaultSort","timestamps","query","buildQuery","useEstimatedCount","length","paginationOptions","forceCountFn","lean","leanWithId","collation","defaultLocale","disableIndexHints","useCustomCountFn","Promise","resolve","countDocuments","hint","_id","result","aggregate","adapter","aggregatePaginate","paginate","docs","JSON","parse","stringify","map","doc","id"],"mappings":"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"}
|
package/dist/findGlobal.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { combineQueries } from 'payload';
|
2
|
-
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js';
|
2
|
+
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js';
|
3
3
|
import { withSession } from './withSession.js';
|
4
4
|
export const findGlobal = async function findGlobal({ slug, locale, req = {}, where }) {
|
5
5
|
const Model = this.globals;
|
package/dist/findGlobal.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/findGlobal.ts"],"sourcesContent":["import type { FindGlobal, PayloadRequest } from 'payload'\n\nimport { combineQueries } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport sanitizeInternalFields from './utilities/sanitizeInternalFields.js'\nimport { withSession } from './withSession.js'\n\nexport const findGlobal: FindGlobal = async function findGlobal(\n this: MongooseAdapter,\n { slug, locale, req = {} as PayloadRequest, where },\n) {\n const Model = this.globals\n const options = {\n ...(await withSession(this, req)),\n lean: true,\n }\n\n const query = await Model.buildQuery({\n globalSlug: slug,\n locale,\n payload: this.payload,\n where: combineQueries({ globalType: { equals: slug } }, where),\n })\n\n let doc = (await Model.findOne(query, {}, options)) as any\n\n if (!doc) {\n return null\n }\n if (doc._id) {\n doc.id = doc._id\n delete doc._id\n }\n\n doc = JSON.parse(JSON.stringify(doc))\n doc = sanitizeInternalFields(doc)\n\n return doc\n}\n"],"names":["combineQueries","sanitizeInternalFields","withSession","findGlobal","slug","locale","req","where","Model","globals","options","lean","query","buildQuery","globalSlug","payload","globalType","equals","doc","findOne","_id","id","JSON","parse","stringify"],"mappings":"AAEA,SAASA,cAAc,QAAQ,UAAS;AAIxC,
|
1
|
+
{"version":3,"sources":["../src/findGlobal.ts"],"sourcesContent":["import type { FindGlobal, PayloadRequest } from 'payload'\n\nimport { combineQueries } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\nimport { withSession } from './withSession.js'\n\nexport const findGlobal: FindGlobal = async function findGlobal(\n this: MongooseAdapter,\n { slug, locale, req = {} as PayloadRequest, where },\n) {\n const Model = this.globals\n const options = {\n ...(await withSession(this, req)),\n lean: true,\n }\n\n const query = await Model.buildQuery({\n globalSlug: slug,\n locale,\n payload: this.payload,\n where: combineQueries({ globalType: { equals: slug } }, where),\n })\n\n let doc = (await Model.findOne(query, {}, options)) as any\n\n if (!doc) {\n return null\n }\n if (doc._id) {\n doc.id = doc._id\n delete doc._id\n }\n\n doc = JSON.parse(JSON.stringify(doc))\n doc = sanitizeInternalFields(doc)\n\n return doc\n}\n"],"names":["combineQueries","sanitizeInternalFields","withSession","findGlobal","slug","locale","req","where","Model","globals","options","lean","query","buildQuery","globalSlug","payload","globalType","equals","doc","findOne","_id","id","JSON","parse","stringify"],"mappings":"AAEA,SAASA,cAAc,QAAQ,UAAS;AAIxC,SAASC,sBAAsB,QAAQ,wCAAuC;AAC9E,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,aAAyB,eAAeA,WAEnD,EAAEC,IAAI,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAAmB,EAAEC,KAAK,EAAE;IAEnD,MAAMC,QAAQ,IAAI,CAACC,OAAO;IAC1B,MAAMC,UAAU;QACd,GAAI,MAAMR,YAAY,IAAI,EAAEI,IAAI;QAChCK,MAAM;IACR;IAEA,MAAMC,QAAQ,MAAMJ,MAAMK,UAAU,CAAC;QACnCC,YAAYV;QACZC;QACAU,SAAS,IAAI,CAACA,OAAO;QACrBR,OAAOP,eAAe;YAAEgB,YAAY;gBAAEC,QAAQb;YAAK;QAAE,GAAGG;IAC1D;IAEA,IAAIW,MAAO,MAAMV,MAAMW,OAAO,CAACP,OAAO,CAAC,GAAGF;IAE1C,IAAI,CAACQ,KAAK;QACR,OAAO;IACT;IACA,IAAIA,IAAIE,GAAG,EAAE;QACXF,IAAIG,EAAE,GAAGH,IAAIE,GAAG;QAChB,OAAOF,IAAIE,GAAG;IAChB;IAEAF,MAAMI,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACN;IAChCA,MAAMjB,uBAAuBiB;IAE7B,OAAOA;AACT,EAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"findGlobalVersions.d.ts","sourceRoot":"","sources":["../src/findGlobalVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAkB,MAAM,SAAS,CAAA;AAUjE,eAAO,MAAM,kBAAkB,EAAE,
|
1
|
+
{"version":3,"file":"findGlobalVersions.d.ts","sourceRoot":"","sources":["../src/findGlobalVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAkB,MAAM,SAAS,CAAA;AAUjE,eAAO,MAAM,kBAAkB,EAAE,kBA4GhC,CAAA"}
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import { buildVersionGlobalFields, flattenWhereToOperators } from 'payload';
|
2
2
|
import { buildSortParam } from './queries/buildSortParam.js';
|
3
|
-
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js';
|
3
|
+
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js';
|
4
4
|
import { withSession } from './withSession.js';
|
5
5
|
export const findGlobalVersions = async function findGlobalVersions({ global, limit, locale, page, pagination, req = {}, skip, sort: sortArg, where }) {
|
6
6
|
const Model = this.versions[global];
|
7
|
-
const versionFields = buildVersionGlobalFields(this.payload.globals.config.find(({ slug })=>slug === global));
|
7
|
+
const versionFields = buildVersionGlobalFields(this.payload.config, this.payload.globals.config.find(({ slug })=>slug === global));
|
8
8
|
const options = {
|
9
9
|
...await withSession(this, req),
|
10
10
|
limit,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/findGlobalVersions.ts"],"sourcesContent":["import type { PaginateOptions } from 'mongoose'\nimport type { FindGlobalVersions, PayloadRequest } from 'payload'\n\nimport { buildVersionGlobalFields, flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport sanitizeInternalFields from './utilities/sanitizeInternalFields.js'\nimport { withSession } from './withSession.js'\n\nexport const findGlobalVersions: FindGlobalVersions = async function findGlobalVersions(\n this: MongooseAdapter,\n {\n global,\n limit,\n locale,\n page,\n pagination,\n req = {} as PayloadRequest,\n skip,\n sort: sortArg,\n where,\n },\n) {\n const Model = this.versions[global]\n const versionFields = buildVersionGlobalFields(\n this.payload.globals.config.find(({ slug }) => slug === global),\n )\n const options = {\n ...(await withSession(this, req)),\n limit,\n skip,\n }\n\n let hasNearConstraint = false\n\n if (where) {\n const constraints = flattenWhereToOperators(where)\n hasNearConstraint = constraints.some((prop) => Object.keys(prop).some((key) => key === 'near'))\n }\n\n let sort\n if (!hasNearConstraint) {\n sort = buildSortParam({\n config: this.payload.config,\n fields: versionFields,\n locale,\n sort: sortArg || '-updatedAt',\n timestamps: true,\n })\n }\n\n const query = await Model.buildQuery({\n globalSlug: global,\n locale,\n payload: this.payload,\n where,\n })\n\n // useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.\n const useEstimatedCount = hasNearConstraint || !query || Object.keys(query).length === 0\n const paginationOptions: PaginateOptions = {\n forceCountFn: hasNearConstraint,\n lean: true,\n leanWithId: true,\n limit,\n options,\n page,\n pagination,\n sort,\n useEstimatedCount,\n }\n\n if (this.collation) {\n const defaultLocale = 'en'\n paginationOptions.collation = {\n locale: locale && locale !== 'all' && locale !== '*' ? locale : defaultLocale,\n ...this.collation,\n }\n }\n\n if (!useEstimatedCount && Object.keys(query).length === 0 && this.disableIndexHints !== true) {\n // Improve the performance of the countDocuments query which is used if useEstimatedCount is set to false by adding\n // a hint. By default, if no hint is provided, MongoDB does not use an indexed field to count the returned documents,\n // which makes queries very slow. This only happens when no query (filter) is provided. If one is provided, it uses\n // the correct indexed field\n paginationOptions.useCustomCountFn = () => {\n return Promise.resolve(\n Model.countDocuments(query, {\n ...options,\n hint: { _id: 1 },\n }),\n )\n }\n }\n\n if (limit >= 0) {\n paginationOptions.limit = limit\n // limit must also be set here, it's ignored when pagination is false\n paginationOptions.options.limit = limit\n\n // Disable pagination if limit is 0\n if (limit === 0) {\n paginationOptions.pagination = false\n }\n }\n\n const result = await Model.paginate(query, paginationOptions)\n const docs = JSON.parse(JSON.stringify(result.docs))\n\n return {\n ...result,\n docs: docs.map((doc) => {\n doc.id = doc._id\n return sanitizeInternalFields(doc)\n }),\n }\n}\n"],"names":["buildVersionGlobalFields","flattenWhereToOperators","buildSortParam","sanitizeInternalFields","withSession","findGlobalVersions","global","limit","locale","page","pagination","req","skip","sort","sortArg","where","Model","versions","versionFields","payload","
|
1
|
+
{"version":3,"sources":["../src/findGlobalVersions.ts"],"sourcesContent":["import type { PaginateOptions } from 'mongoose'\nimport type { FindGlobalVersions, PayloadRequest } from 'payload'\n\nimport { buildVersionGlobalFields, flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\nimport { withSession } from './withSession.js'\n\nexport const findGlobalVersions: FindGlobalVersions = async function findGlobalVersions(\n this: MongooseAdapter,\n {\n global,\n limit,\n locale,\n page,\n pagination,\n req = {} as PayloadRequest,\n skip,\n sort: sortArg,\n where,\n },\n) {\n const Model = this.versions[global]\n const versionFields = buildVersionGlobalFields(\n this.payload.config,\n this.payload.globals.config.find(({ slug }) => slug === global),\n )\n const options = {\n ...(await withSession(this, req)),\n limit,\n skip,\n }\n\n let hasNearConstraint = false\n\n if (where) {\n const constraints = flattenWhereToOperators(where)\n hasNearConstraint = constraints.some((prop) => Object.keys(prop).some((key) => key === 'near'))\n }\n\n let sort\n if (!hasNearConstraint) {\n sort = buildSortParam({\n config: this.payload.config,\n fields: versionFields,\n locale,\n sort: sortArg || '-updatedAt',\n timestamps: true,\n })\n }\n\n const query = await Model.buildQuery({\n globalSlug: global,\n locale,\n payload: this.payload,\n where,\n })\n\n // useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.\n const useEstimatedCount = hasNearConstraint || !query || Object.keys(query).length === 0\n const paginationOptions: PaginateOptions = {\n forceCountFn: hasNearConstraint,\n lean: true,\n leanWithId: true,\n limit,\n options,\n page,\n pagination,\n sort,\n useEstimatedCount,\n }\n\n if (this.collation) {\n const defaultLocale = 'en'\n paginationOptions.collation = {\n locale: locale && locale !== 'all' && locale !== '*' ? locale : defaultLocale,\n ...this.collation,\n }\n }\n\n if (!useEstimatedCount && Object.keys(query).length === 0 && this.disableIndexHints !== true) {\n // Improve the performance of the countDocuments query which is used if useEstimatedCount is set to false by adding\n // a hint. By default, if no hint is provided, MongoDB does not use an indexed field to count the returned documents,\n // which makes queries very slow. This only happens when no query (filter) is provided. If one is provided, it uses\n // the correct indexed field\n paginationOptions.useCustomCountFn = () => {\n return Promise.resolve(\n Model.countDocuments(query, {\n ...options,\n hint: { _id: 1 },\n }),\n )\n }\n }\n\n if (limit >= 0) {\n paginationOptions.limit = limit\n // limit must also be set here, it's ignored when pagination is false\n paginationOptions.options.limit = limit\n\n // Disable pagination if limit is 0\n if (limit === 0) {\n paginationOptions.pagination = false\n }\n }\n\n const result = await Model.paginate(query, paginationOptions)\n const docs = JSON.parse(JSON.stringify(result.docs))\n\n return {\n ...result,\n docs: docs.map((doc) => {\n doc.id = doc._id\n return sanitizeInternalFields(doc)\n }),\n }\n}\n"],"names":["buildVersionGlobalFields","flattenWhereToOperators","buildSortParam","sanitizeInternalFields","withSession","findGlobalVersions","global","limit","locale","page","pagination","req","skip","sort","sortArg","where","Model","versions","versionFields","payload","config","globals","find","slug","options","hasNearConstraint","constraints","some","prop","Object","keys","key","fields","timestamps","query","buildQuery","globalSlug","useEstimatedCount","length","paginationOptions","forceCountFn","lean","leanWithId","collation","defaultLocale","disableIndexHints","useCustomCountFn","Promise","resolve","countDocuments","hint","_id","result","paginate","docs","JSON","parse","stringify","map","doc","id"],"mappings":"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"}
|
package/dist/findOne.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../src/findOne.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAY,OAAO,EAAkB,MAAM,SAAS,CAAA;
|
1
|
+
{"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../src/findOne.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAY,OAAO,EAAkB,MAAM,SAAS,CAAA;AAQhE,eAAO,MAAM,OAAO,EAAE,OA6CrB,CAAA"}
|
package/dist/findOne.js
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
import
|
1
|
+
import { buildJoinAggregation } from './utilities/buildJoinAggregation.js';
|
2
|
+
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js';
|
2
3
|
import { withSession } from './withSession.js';
|
3
|
-
export const findOne = async function findOne({ collection, locale, req = {}, where }) {
|
4
|
+
export const findOne = async function findOne({ collection, joins, locale, req = {}, where }) {
|
4
5
|
const Model = this.collections[collection];
|
6
|
+
const collectionConfig = this.payload.collections[collection].config;
|
5
7
|
const options = {
|
6
8
|
...await withSession(this, req),
|
7
9
|
lean: true
|
@@ -11,7 +13,21 @@ export const findOne = async function findOne({ collection, locale, req = {}, wh
|
|
11
13
|
payload: this.payload,
|
12
14
|
where
|
13
15
|
});
|
14
|
-
const
|
16
|
+
const aggregate = await buildJoinAggregation({
|
17
|
+
adapter: this,
|
18
|
+
collection,
|
19
|
+
collectionConfig,
|
20
|
+
joins,
|
21
|
+
limit: 1,
|
22
|
+
locale,
|
23
|
+
query
|
24
|
+
});
|
25
|
+
let doc;
|
26
|
+
if (aggregate) {
|
27
|
+
[doc] = await Model.aggregate(aggregate, options);
|
28
|
+
} else {
|
29
|
+
doc = await Model.findOne(query, {}, options);
|
30
|
+
}
|
15
31
|
if (!doc) {
|
16
32
|
return null;
|
17
33
|
}
|
package/dist/findOne.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/findOne.ts"],"sourcesContent":["import type { MongooseQueryOptions } from 'mongoose'\nimport type { Document, FindOne, PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport sanitizeInternalFields from './utilities/sanitizeInternalFields.js'\nimport { withSession } from './withSession.js'\n\nexport const findOne: FindOne = async function findOne(\n this: MongooseAdapter,\n { collection, locale, req = {} as PayloadRequest, where },\n) {\n const Model = this.collections[collection]\n const options: MongooseQueryOptions = {\n ...(await withSession(this, req)),\n lean: true,\n }\n\n const query = await Model.buildQuery({\n locale,\n payload: this.payload,\n where,\n })\n\n const doc = await Model.findOne(query, {}, options)\n\n if (!doc) {\n return null\n }\n\n let result: Document = JSON.parse(JSON.stringify(doc))\n\n // custom id type reset\n result.id = result._id\n result = sanitizeInternalFields(result)\n\n return result\n}\n"],"names":["sanitizeInternalFields","withSession","findOne","collection","locale","req","where","Model","collections","options","lean","query","buildQuery","
|
1
|
+
{"version":3,"sources":["../src/findOne.ts"],"sourcesContent":["import type { MongooseQueryOptions } from 'mongoose'\nimport type { Document, FindOne, PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildJoinAggregation } from './utilities/buildJoinAggregation.js'\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\nimport { withSession } from './withSession.js'\n\nexport const findOne: FindOne = async function findOne(\n this: MongooseAdapter,\n { collection, joins, locale, req = {} as PayloadRequest, where },\n) {\n const Model = this.collections[collection]\n const collectionConfig = this.payload.collections[collection].config\n const options: MongooseQueryOptions = {\n ...(await withSession(this, req)),\n lean: true,\n }\n\n const query = await Model.buildQuery({\n locale,\n payload: this.payload,\n where,\n })\n\n const aggregate = await buildJoinAggregation({\n adapter: this,\n collection,\n collectionConfig,\n joins,\n limit: 1,\n locale,\n query,\n })\n\n let doc\n if (aggregate) {\n ;[doc] = await Model.aggregate(aggregate, options)\n } else {\n doc = await Model.findOne(query, {}, options)\n }\n\n if (!doc) {\n return null\n }\n\n let result: Document = JSON.parse(JSON.stringify(doc))\n\n // custom id type reset\n result.id = result._id\n result = sanitizeInternalFields(result)\n\n return result\n}\n"],"names":["buildJoinAggregation","sanitizeInternalFields","withSession","findOne","collection","joins","locale","req","where","Model","collections","collectionConfig","payload","config","options","lean","query","buildQuery","aggregate","adapter","limit","doc","result","JSON","parse","stringify","id","_id"],"mappings":"AAKA,SAASA,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,sBAAsB,QAAQ,wCAAuC;AAC9E,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,UAAmB,eAAeA,QAE7C,EAAEC,UAAU,EAAEC,KAAK,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAAmB,EAAEC,KAAK,EAAE;IAEhE,MAAMC,QAAQ,IAAI,CAACC,WAAW,CAACN,WAAW;IAC1C,MAAMO,mBAAmB,IAAI,CAACC,OAAO,CAACF,WAAW,CAACN,WAAW,CAACS,MAAM;IACpE,MAAMC,UAAgC;QACpC,GAAI,MAAMZ,YAAY,IAAI,EAAEK,IAAI;QAChCQ,MAAM;IACR;IAEA,MAAMC,QAAQ,MAAMP,MAAMQ,UAAU,CAAC;QACnCX;QACAM,SAAS,IAAI,CAACA,OAAO;QACrBJ;IACF;IAEA,MAAMU,YAAY,MAAMlB,qBAAqB;QAC3CmB,SAAS,IAAI;QACbf;QACAO;QACAN;QACAe,OAAO;QACPd;QACAU;IACF;IAEA,IAAIK;IACJ,IAAIH,WAAW;QACZ,CAACG,IAAI,GAAG,MAAMZ,MAAMS,SAAS,CAACA,WAAWJ;IAC5C,OAAO;QACLO,MAAM,MAAMZ,MAAMN,OAAO,CAACa,OAAO,CAAC,GAAGF;IACvC;IAEA,IAAI,CAACO,KAAK;QACR,OAAO;IACT;IAEA,IAAIC,SAAmBC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACJ;IAEjD,uBAAuB;IACvBC,OAAOI,EAAE,GAAGJ,OAAOK,GAAG;IACtBL,SAASrB,uBAAuBqB;IAEhC,OAAOA;AACT,EAAC"}
|
package/dist/findVersions.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { flattenWhereToOperators } from 'payload';
|
2
2
|
import { buildSortParam } from './queries/buildSortParam.js';
|
3
|
-
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js';
|
3
|
+
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js';
|
4
4
|
import { withSession } from './withSession.js';
|
5
5
|
export const findVersions = async function findVersions({ collection, limit, locale, page, pagination, req = {}, skip, sort: sortArg, where }) {
|
6
6
|
const Model = this.versions[collection];
|