@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.
@@ -1,3 +1,3 @@
1
- import { type DeleteVersions } from 'payload';
1
+ import type { DeleteVersions } from 'payload';
2
2
  export declare const deleteVersions: DeleteVersions;
3
3
  //# sourceMappingURL=deleteVersions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deleteVersions.d.ts","sourceRoot":"","sources":["../src/deleteVersions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,cAAc,EAAE,MAAM,SAAS,CAAA;AAQ3E,eAAO,MAAM,cAAc,EAAE,cAoB5B,CAAA"}
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"}
@@ -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
- const { collectionConfig, Model } = getCollection({
7
- adapter: this,
8
- collectionSlug,
9
- versions: true
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: buildVersionCollectionFields(this.payload.config, collectionConfig, true),
30
+ fields,
15
31
  locale,
16
32
  where
17
33
  });
18
- await Model.deleteMany(query, {
34
+ await VersionsModel.deleteMany(query, {
19
35
  session
20
36
  });
21
37
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/deleteVersions.ts"],"sourcesContent":["import { buildVersionCollectionFields, type DeleteVersions } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\n\nexport const deleteVersions: DeleteVersions = async function deleteVersions(\n this: MongooseAdapter,\n { collection: collectionSlug, locale, req, where },\n) {\n const { collectionConfig, Model } = getCollection({\n adapter: this,\n collectionSlug,\n versions: true,\n })\n\n const session = await getSession(this, req)\n\n const query = await buildQuery({\n adapter: this,\n fields: buildVersionCollectionFields(this.payload.config, collectionConfig, true),\n locale,\n where,\n })\n\n await Model.deleteMany(query, { session })\n}\n"],"names":["buildVersionCollectionFields","buildQuery","getCollection","getSession","deleteVersions","collection","collectionSlug","locale","req","where","collectionConfig","Model","adapter","versions","session","query","fields","payload","config","deleteMany"],"mappings":"AAAA,SAASA,4BAA4B,QAA6B,UAAS;AAI3E,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SAASC,UAAU,QAAQ,4BAA2B;AAEtD,OAAO,MAAMC,iBAAiC,eAAeA,eAE3D,EAAEC,YAAYC,cAAc,EAAEC,MAAM,EAAEC,GAAG,EAAEC,KAAK,EAAE;IAElD,MAAM,EAAEC,gBAAgB,EAAEC,KAAK,EAAE,GAAGT,cAAc;QAChDU,SAAS,IAAI;QACbN;QACAO,UAAU;IACZ;IAEA,MAAMC,UAAU,MAAMX,WAAW,IAAI,EAAEK;IAEvC,MAAMO,QAAQ,MAAMd,WAAW;QAC7BW,SAAS,IAAI;QACbI,QAAQhB,6BAA6B,IAAI,CAACiB,OAAO,CAACC,MAAM,EAAER,kBAAkB;QAC5EH;QACAE;IACF;IAEA,MAAME,MAAMQ,UAAU,CAACJ,OAAO;QAAED;IAAQ;AAC1C,EAAC"}
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.42.0-internal.f9d0258",
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.42.0-internal.f9d0258"
53
+ "payload": "3.43.0-canary.0"
54
54
  },
55
55
  "peerDependencies": {
56
- "payload": "3.42.0-internal.f9d0258"
56
+ "payload": "3.43.0-canary.0"
57
57
  },
58
58
  "scripts": {
59
59
  "build": "pnpm build:types && pnpm build:swc",