@payloadcms/db-mongodb 3.42.0-internal.f9d0258 → 3.43.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/deleteVersions.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"deleteVersions.d.ts","sourceRoot":"","sources":["../src/deleteVersions.ts"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"deleteVersions.d.ts","sourceRoot":"","sources":["../src/deleteVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,SAAS,CAAA;AAW7D,eAAO,MAAM,cAAc,EAAE,cAqC5B,CAAA"}
|
package/dist/deleteVersions.js
CHANGED
@@ -1,21 +1,37 @@
|
|
1
|
-
import { buildVersionCollectionFields } from 'payload';
|
1
|
+
import { APIError, buildVersionCollectionFields, buildVersionGlobalFields } from 'payload';
|
2
2
|
import { buildQuery } from './queries/buildQuery.js';
|
3
|
-
import { getCollection } from './utilities/getEntity.js';
|
3
|
+
import { getCollection, getGlobal } from './utilities/getEntity.js';
|
4
4
|
import { getSession } from './utilities/getSession.js';
|
5
|
-
export const deleteVersions = async function deleteVersions({ collection: collectionSlug, locale, req, where }) {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
export const deleteVersions = async function deleteVersions({ collection: collectionSlug, globalSlug, locale, req, where }) {
|
6
|
+
let fields;
|
7
|
+
let VersionsModel;
|
8
|
+
if (globalSlug) {
|
9
|
+
const { globalConfig, Model } = getGlobal({
|
10
|
+
adapter: this,
|
11
|
+
globalSlug,
|
12
|
+
versions: true
|
13
|
+
});
|
14
|
+
fields = buildVersionGlobalFields(this.payload.config, globalConfig, true);
|
15
|
+
VersionsModel = Model;
|
16
|
+
} else if (collectionSlug) {
|
17
|
+
const { collectionConfig, Model } = getCollection({
|
18
|
+
adapter: this,
|
19
|
+
collectionSlug,
|
20
|
+
versions: true
|
21
|
+
});
|
22
|
+
fields = buildVersionCollectionFields(this.payload.config, collectionConfig, true);
|
23
|
+
VersionsModel = Model;
|
24
|
+
} else {
|
25
|
+
throw new APIError('Either collection or globalSlug must be passed.');
|
26
|
+
}
|
11
27
|
const session = await getSession(this, req);
|
12
28
|
const query = await buildQuery({
|
13
29
|
adapter: this,
|
14
|
-
fields
|
30
|
+
fields,
|
15
31
|
locale,
|
16
32
|
where
|
17
33
|
});
|
18
|
-
await
|
34
|
+
await VersionsModel.deleteMany(query, {
|
19
35
|
session
|
20
36
|
});
|
21
37
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/deleteVersions.ts"],"sourcesContent":["import { buildVersionCollectionFields,
|
1
|
+
{"version":3,"sources":["../src/deleteVersions.ts"],"sourcesContent":["import type { DeleteVersions, FlattenedField } from 'payload'\n\nimport { APIError, buildVersionCollectionFields, buildVersionGlobalFields } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\nimport type { CollectionModel } from './types.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { getCollection, getGlobal } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\n\nexport const deleteVersions: DeleteVersions = async function deleteVersions(\n this: MongooseAdapter,\n { collection: collectionSlug, globalSlug, locale, req, where },\n) {\n let fields: FlattenedField[]\n let VersionsModel: CollectionModel\n\n if (globalSlug) {\n const { globalConfig, Model } = getGlobal({\n adapter: this,\n globalSlug,\n versions: true,\n })\n fields = buildVersionGlobalFields(this.payload.config, globalConfig, true)\n VersionsModel = Model\n } else if (collectionSlug) {\n const { collectionConfig, Model } = getCollection({\n adapter: this,\n collectionSlug,\n versions: true,\n })\n fields = buildVersionCollectionFields(this.payload.config, collectionConfig, true)\n VersionsModel = Model\n } else {\n throw new APIError('Either collection or globalSlug must be passed.')\n }\n\n const session = await getSession(this, req)\n\n const query = await buildQuery({\n adapter: this,\n fields,\n locale,\n where,\n })\n\n await VersionsModel.deleteMany(query, { session })\n}\n"],"names":["APIError","buildVersionCollectionFields","buildVersionGlobalFields","buildQuery","getCollection","getGlobal","getSession","deleteVersions","collection","collectionSlug","globalSlug","locale","req","where","fields","VersionsModel","globalConfig","Model","adapter","versions","payload","config","collectionConfig","session","query","deleteMany"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,4BAA4B,EAAEC,wBAAwB,QAAQ,UAAS;AAK1F,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,aAAa,EAAEC,SAAS,QAAQ,2BAA0B;AACnE,SAASC,UAAU,QAAQ,4BAA2B;AAEtD,OAAO,MAAMC,iBAAiC,eAAeA,eAE3D,EAAEC,YAAYC,cAAc,EAAEC,UAAU,EAAEC,MAAM,EAAEC,GAAG,EAAEC,KAAK,EAAE;IAE9D,IAAIC;IACJ,IAAIC;IAEJ,IAAIL,YAAY;QACd,MAAM,EAAEM,YAAY,EAAEC,KAAK,EAAE,GAAGZ,UAAU;YACxCa,SAAS,IAAI;YACbR;YACAS,UAAU;QACZ;QACAL,SAASZ,yBAAyB,IAAI,CAACkB,OAAO,CAACC,MAAM,EAAEL,cAAc;QACrED,gBAAgBE;IAClB,OAAO,IAAIR,gBAAgB;QACzB,MAAM,EAAEa,gBAAgB,EAAEL,KAAK,EAAE,GAAGb,cAAc;YAChDc,SAAS,IAAI;YACbT;YACAU,UAAU;QACZ;QACAL,SAASb,6BAA6B,IAAI,CAACmB,OAAO,CAACC,MAAM,EAAEC,kBAAkB;QAC7EP,gBAAgBE;IAClB,OAAO;QACL,MAAM,IAAIjB,SAAS;IACrB;IAEA,MAAMuB,UAAU,MAAMjB,WAAW,IAAI,EAAEM;IAEvC,MAAMY,QAAQ,MAAMrB,WAAW;QAC7Be,SAAS,IAAI;QACbJ;QACAH;QACAE;IACF;IAEA,MAAME,cAAcU,UAAU,CAACD,OAAO;QAAED;IAAQ;AAClD,EAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@payloadcms/db-mongodb",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.43.0-canary.0",
|
4
4
|
"description": "The officially supported MongoDB database adapter for Payload",
|
5
5
|
"homepage": "https://payloadcms.com",
|
6
6
|
"repository": {
|
@@ -50,10 +50,10 @@
|
|
50
50
|
"mongodb": "6.12.0",
|
51
51
|
"mongodb-memory-server": "10.1.4",
|
52
52
|
"@payloadcms/eslint-config": "3.28.0",
|
53
|
-
"payload": "3.
|
53
|
+
"payload": "3.43.0-canary.0"
|
54
54
|
},
|
55
55
|
"peerDependencies": {
|
56
|
-
"payload": "3.
|
56
|
+
"payload": "3.43.0-canary.0"
|
57
57
|
},
|
58
58
|
"scripts": {
|
59
59
|
"build": "pnpm build:types && pnpm build:swc",
|