@payloadcms/db-mongodb 3.0.0-alpha.6 → 3.0.0-alpha.61
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/README.md +0 -2
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +20 -25
- package/dist/connect.js.map +1 -0
- package/dist/create.js +6 -21
- package/dist/create.js.map +1 -0
- package/dist/createGlobal.js +6 -21
- package/dist/createGlobal.js.map +1 -0
- package/dist/createGlobalVersion.js +4 -14
- package/dist/createGlobalVersion.js.map +1 -0
- package/dist/createMigration.d.ts.map +1 -1
- package/dist/createMigration.js +15 -25
- package/dist/createMigration.js.map +1 -0
- package/dist/createVersion.js +4 -14
- package/dist/createVersion.js.map +1 -0
- package/dist/deleteMany.js +4 -14
- package/dist/deleteMany.js.map +1 -0
- package/dist/deleteOne.js +6 -21
- package/dist/deleteOne.js.map +1 -0
- package/dist/deleteVersions.js +4 -14
- package/dist/deleteVersions.js.map +1 -0
- package/dist/destroy.js +5 -21
- package/dist/destroy.js.map +1 -0
- package/dist/find.js +10 -25
- package/dist/find.js.map +1 -0
- package/dist/findGlobal.js +8 -23
- package/dist/findGlobal.js.map +1 -0
- package/dist/findGlobalVersions.js +12 -27
- package/dist/findGlobalVersions.js.map +1 -0
- package/dist/findOne.js +6 -21
- package/dist/findOne.js.map +1 -0
- package/dist/findVersions.js +10 -25
- package/dist/findVersions.js.map +1 -0
- package/dist/index.d.ts +36 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +65 -80
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +33 -39
- package/dist/init.js.map +1 -0
- package/dist/migrateFresh.d.ts +1 -1
- package/dist/migrateFresh.d.ts.map +1 -1
- package/dist/migrateFresh.js +13 -26
- package/dist/migrateFresh.js.map +1 -0
- package/dist/models/buildCollectionSchema.d.ts +25 -0
- package/dist/models/buildCollectionSchema.d.ts.map +1 -1
- package/dist/models/buildCollectionSchema.js +8 -23
- package/dist/models/buildCollectionSchema.js.map +1 -0
- package/dist/models/buildGlobalModel.d.ts +1 -1
- package/dist/models/buildGlobalModel.d.ts.map +1 -1
- package/dist/models/buildGlobalModel.js +9 -24
- package/dist/models/buildGlobalModel.js.map +1 -0
- package/dist/models/buildSchema.d.ts +26 -2
- package/dist/models/buildSchema.d.ts.map +1 -1
- package/dist/models/buildSchema.js +23 -33
- package/dist/models/buildSchema.js.map +1 -0
- package/dist/queries/buildAndOrConditions.js +4 -14
- package/dist/queries/buildAndOrConditions.js.map +1 -0
- package/dist/queries/buildQuery.js +6 -16
- package/dist/queries/buildQuery.js.map +1 -0
- package/dist/queries/buildSearchParams.d.ts.map +1 -1
- package/dist/queries/buildSearchParams.js +21 -32
- package/dist/queries/buildSearchParams.js.map +1 -0
- package/dist/queries/buildSortParam.d.ts +25 -0
- package/dist/queries/buildSortParam.d.ts.map +1 -1
- package/dist/queries/buildSortParam.js +4 -14
- package/dist/queries/buildSortParam.js.map +1 -0
- package/dist/queries/getLocalizedSortProperty.js +8 -18
- package/dist/queries/getLocalizedSortProperty.js.map +1 -0
- package/dist/queries/getLocalizedSortProperty.spec.js +19 -23
- package/dist/queries/getLocalizedSortProperty.spec.js.map +1 -0
- package/dist/queries/mock.js +1 -2
- package/dist/queries/mock.js.map +1 -0
- package/dist/queries/operatorMap.js +2 -12
- package/dist/queries/operatorMap.js.map +1 -0
- package/dist/queries/parseParams.js +12 -27
- package/dist/queries/parseParams.js.map +1 -0
- package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
- package/dist/queries/sanitizeQueryValue.js +9 -24
- package/dist/queries/sanitizeQueryValue.js.map +1 -0
- package/dist/queryDrafts.js +11 -26
- package/dist/queryDrafts.js.map +1 -0
- package/dist/testCredentials.js +4 -25
- package/dist/testCredentials.js.map +1 -0
- package/dist/transactions/beginTransaction.js +6 -16
- package/dist/transactions/beginTransaction.js.map +1 -0
- package/dist/transactions/commitTransaction.js +2 -12
- package/dist/transactions/commitTransaction.js.map +1 -0
- package/dist/transactions/rollbackTransaction.js +2 -12
- package/dist/transactions/rollbackTransaction.js.map +1 -0
- package/dist/types.d.ts +26 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -5
- package/dist/types.js.map +1 -0
- package/dist/updateGlobal.js +6 -21
- package/dist/updateGlobal.js.map +1 -0
- package/dist/updateGlobalVersion.d.ts +1 -1
- package/dist/updateGlobalVersion.d.ts.map +1 -1
- package/dist/updateGlobalVersion.js +4 -14
- package/dist/updateGlobalVersion.js.map +1 -0
- package/dist/updateOne.d.ts.map +1 -1
- package/dist/updateOne.js +8 -23
- package/dist/updateOne.js.map +1 -0
- package/dist/updateVersion.js +4 -14
- package/dist/updateVersion.js.map +1 -0
- package/dist/utilities/getDBName.d.ts +19 -0
- package/dist/utilities/getDBName.d.ts.map +1 -0
- package/dist/utilities/getDBName.js +19 -0
- package/dist/utilities/getDBName.js.map +1 -0
- package/dist/utilities/handleError.js +6 -21
- package/dist/utilities/handleError.js.map +1 -0
- package/dist/utilities/sanitizeInternalFields.d.ts.map +1 -1
- package/dist/utilities/sanitizeInternalFields.js +2 -12
- package/dist/utilities/sanitizeInternalFields.js.map +1 -0
- package/dist/withSession.d.ts +26 -1
- package/dist/withSession.d.ts.map +1 -1
- package/dist/withSession.js +5 -12
- package/dist/withSession.js.map +1 -0
- package/package.json +18 -10
- package/src/index.ts +198 -0
package/dist/find.js
CHANGED
|
@@ -1,34 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return find;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _database = require("payload/database");
|
|
12
|
-
const _buildSortParam = require("./queries/buildSortParam");
|
|
13
|
-
const _sanitizeInternalFields = /*#__PURE__*/ _interop_require_default(require("./utilities/sanitizeInternalFields"));
|
|
14
|
-
const _withSession = require("./withSession");
|
|
15
|
-
function _interop_require_default(obj) {
|
|
16
|
-
return obj && obj.__esModule ? obj : {
|
|
17
|
-
default: obj
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
const find = async function find({ collection, limit, locale, page, pagination, req = {}, sort: sortArg, where }) {
|
|
1
|
+
import { flattenWhereToOperators } from 'payload/database';
|
|
2
|
+
import { buildSortParam } from './queries/buildSortParam.js';
|
|
3
|
+
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js';
|
|
4
|
+
import { withSession } from './withSession.js';
|
|
5
|
+
export const find = async function find({ collection, limit, locale, page, pagination, req = {}, sort: sortArg, where }) {
|
|
21
6
|
const Model = this.collections[collection];
|
|
22
7
|
const collectionConfig = this.payload.collections[collection].config;
|
|
23
|
-
const options =
|
|
8
|
+
const options = withSession(this, req.transactionID);
|
|
24
9
|
let hasNearConstraint = false;
|
|
25
10
|
if (where) {
|
|
26
|
-
const constraints =
|
|
11
|
+
const constraints = flattenWhereToOperators(where);
|
|
27
12
|
hasNearConstraint = constraints.some((prop)=>Object.keys(prop).some((key)=>key === 'near'));
|
|
28
13
|
}
|
|
29
14
|
let sort;
|
|
30
15
|
if (!hasNearConstraint) {
|
|
31
|
-
sort =
|
|
16
|
+
sort = buildSortParam({
|
|
32
17
|
config: this.payload.config,
|
|
33
18
|
fields: collectionConfig.fields,
|
|
34
19
|
locale,
|
|
@@ -83,9 +68,9 @@ const find = async function find({ collection, limit, locale, page, pagination,
|
|
|
83
68
|
docs: docs.map((doc)=>{
|
|
84
69
|
// eslint-disable-next-line no-param-reassign
|
|
85
70
|
doc.id = doc._id;
|
|
86
|
-
return (
|
|
71
|
+
return sanitizeInternalFields(doc);
|
|
87
72
|
})
|
|
88
73
|
};
|
|
89
74
|
};
|
|
90
75
|
|
|
91
|
-
//# sourceMappingURL=
|
|
76
|
+
//# sourceMappingURL=find.js.map
|
package/dist/find.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/find.ts"],"sourcesContent":["import type { PaginateOptions } from 'mongoose'\nimport type { Find } from 'payload/database'\nimport type { PayloadRequest } from 'payload/types'\n\nimport { flattenWhereToOperators } from 'payload/database'\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 { collection, limit, locale, page, pagination, req = {} as PayloadRequest, sort: sortArg, where },\n) {\n const Model = this.collections[collection]\n const collectionConfig = this.payload.collections[collection].config\n const options = withSession(this, req.transactionID)\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 sort,\n useEstimatedCount,\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 // eslint-disable-next-line no-param-reassign\n doc.id = doc._id\n return sanitizeInternalFields(doc)\n }),\n }\n}\n"],"names":["flattenWhereToOperators","buildSortParam","sanitizeInternalFields","withSession","find","collection","limit","locale","page","pagination","req","sort","sortArg","where","Model","collections","collectionConfig","payload","config","options","transactionID","hasNearConstraint","constraints","some","prop","Object","keys","key","fields","defaultSort","timestamps","query","buildQuery","useEstimatedCount","length","paginationOptions","forceCountFn","lean","leanWithId","disableIndexHints","useCustomCountFn","Promise","resolve","countDocuments","hint","_id","result","paginate","docs","JSON","parse","stringify","map","doc","id"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,uBAAuB,QAAQ,mBAAkB;AAI1D,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,OAAOC,4BAA4B,wCAAuC;AAC1E,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,OAAa,eAAeA,KAEvC,EAAEC,UAAU,EAAEC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,UAAU,EAAEC,MAAM,CAAC,CAAmB,EAAEC,MAAMC,OAAO,EAAEC,KAAK,EAAE;IAEjG,MAAMC,QAAQ,IAAI,CAACC,WAAW,CAACV,WAAW;IAC1C,MAAMW,mBAAmB,IAAI,CAACC,OAAO,CAACF,WAAW,CAACV,WAAW,CAACa,MAAM;IACpE,MAAMC,UAAUhB,YAAY,IAAI,EAAEO,IAAIU,aAAa;IAEnD,IAAIC,oBAAoB;IAExB,IAAIR,OAAO;QACT,MAAMS,cAActB,wBAAwBa;QAC5CQ,oBAAoBC,YAAYC,IAAI,CAAC,CA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CAACL,OAAOE,IAAI;IAElD,OAAO;QACL,GAAGF,MAAM;QACTE,MAAMA,KAAKI,GAAG,CAAC,CAACC;YACd,6CAA6C;YAC7CA,IAAIC,EAAE,GAAGD,IAAIR,GAAG;YAChB,OAAO3C,uBAAuBmD;QAChC;IACF;AACF,EAAC"}
|
package/dist/findGlobal.js
CHANGED
|
@@ -1,32 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
})
|
|
5
|
-
Object.defineProperty(exports, "findGlobal", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return findGlobal;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _database = require("payload/database");
|
|
12
|
-
const _sanitizeInternalFields = /*#__PURE__*/ _interop_require_default(require("./utilities/sanitizeInternalFields"));
|
|
13
|
-
const _withSession = require("./withSession");
|
|
14
|
-
function _interop_require_default(obj) {
|
|
15
|
-
return obj && obj.__esModule ? obj : {
|
|
16
|
-
default: obj
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
const findGlobal = async function findGlobal({ locale, req = {}, slug, where }) {
|
|
1
|
+
import { combineQueries } from 'payload/database';
|
|
2
|
+
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js';
|
|
3
|
+
import { withSession } from './withSession.js';
|
|
4
|
+
export const findGlobal = async function findGlobal({ slug, locale, req = {}, where }) {
|
|
20
5
|
const Model = this.globals;
|
|
21
6
|
const options = {
|
|
22
|
-
...
|
|
7
|
+
...withSession(this, req.transactionID),
|
|
23
8
|
lean: true
|
|
24
9
|
};
|
|
25
10
|
const query = await Model.buildQuery({
|
|
26
11
|
globalSlug: slug,
|
|
27
12
|
locale,
|
|
28
13
|
payload: this.payload,
|
|
29
|
-
where:
|
|
14
|
+
where: combineQueries({
|
|
30
15
|
globalType: {
|
|
31
16
|
equals: slug
|
|
32
17
|
}
|
|
@@ -41,8 +26,8 @@ const findGlobal = async function findGlobal({ locale, req = {}, slug, where })
|
|
|
41
26
|
delete doc._id;
|
|
42
27
|
}
|
|
43
28
|
doc = JSON.parse(JSON.stringify(doc));
|
|
44
|
-
doc = (
|
|
29
|
+
doc = sanitizeInternalFields(doc);
|
|
45
30
|
return doc;
|
|
46
31
|
};
|
|
47
32
|
|
|
48
|
-
//# sourceMappingURL=
|
|
33
|
+
//# sourceMappingURL=findGlobal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/findGlobal.ts"],"sourcesContent":["import type { FindGlobal } from 'payload/database'\nimport type { PayloadRequest } from 'payload/types'\n\nimport { combineQueries } from 'payload/database'\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 ...withSession(this, req.transactionID),\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","transactionID","lean","query","buildQuery","globalSlug","payload","globalType","equals","doc","findOne","_id","id","JSON","parse","stringify"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,cAAc,QAAQ,mBAAkB;AAIjD,OAAOC,4BAA4B,wCAAuC;AAC1E,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,GAAGR,YAAY,IAAI,EAAEI,IAAIK,aAAa,CAAC;QACvCC,MAAM;IACR;IAEA,MAAMC,QAAQ,MAAML,MAAMM,UAAU,CAAC;QACnCC,YAAYX;QACZC;QACAW,SAAS,IAAI,CAACA,OAAO;QACrBT,OAAOP,eAAe;YAAEiB,YAAY;gBAAEC,QAAQd;YAAK;QAAE,GAAGG;IAC1D;IAEA,IAAIY,MAAO,MAAMX,MAAMY,OAAO,CAACP,OAAO,CAAC,GAAGH;IAE1C,IAAI,CAACS,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,MAAMlB,uBAAuBkB;IAE7B,OAAOA;AACT,EAAC"}
|
|
@@ -1,39 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
get: function() {
|
|
8
|
-
return findGlobalVersions;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _database = require("payload/database");
|
|
12
|
-
const _versions = require("payload/versions");
|
|
13
|
-
const _buildSortParam = require("./queries/buildSortParam");
|
|
14
|
-
const _sanitizeInternalFields = /*#__PURE__*/ _interop_require_default(require("./utilities/sanitizeInternalFields"));
|
|
15
|
-
const _withSession = require("./withSession");
|
|
16
|
-
function _interop_require_default(obj) {
|
|
17
|
-
return obj && obj.__esModule ? obj : {
|
|
18
|
-
default: obj
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
const findGlobalVersions = async function findGlobalVersions({ global, limit, locale, page, pagination, req = {}, skip, sort: sortArg, where }) {
|
|
1
|
+
import { flattenWhereToOperators } from 'payload/database';
|
|
2
|
+
import { buildVersionGlobalFields } from 'payload/versions';
|
|
3
|
+
import { buildSortParam } from './queries/buildSortParam.js';
|
|
4
|
+
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js';
|
|
5
|
+
import { withSession } from './withSession.js';
|
|
6
|
+
export const findGlobalVersions = async function findGlobalVersions({ global, limit, locale, page, pagination, req = {}, skip, sort: sortArg, where }) {
|
|
22
7
|
const Model = this.versions[global];
|
|
23
|
-
const versionFields =
|
|
8
|
+
const versionFields = buildVersionGlobalFields(this.payload.globals.config.find(({ slug })=>slug === global));
|
|
24
9
|
const options = {
|
|
25
|
-
...
|
|
10
|
+
...withSession(this, req.transactionID),
|
|
26
11
|
limit,
|
|
27
12
|
skip
|
|
28
13
|
};
|
|
29
14
|
let hasNearConstraint = false;
|
|
30
15
|
if (where) {
|
|
31
|
-
const constraints =
|
|
16
|
+
const constraints = flattenWhereToOperators(where);
|
|
32
17
|
hasNearConstraint = constraints.some((prop)=>Object.keys(prop).some((key)=>key === 'near'));
|
|
33
18
|
}
|
|
34
19
|
let sort;
|
|
35
20
|
if (!hasNearConstraint) {
|
|
36
|
-
sort =
|
|
21
|
+
sort = buildSortParam({
|
|
37
22
|
config: this.payload.config,
|
|
38
23
|
fields: versionFields,
|
|
39
24
|
locale,
|
|
@@ -90,9 +75,9 @@ const findGlobalVersions = async function findGlobalVersions({ global, limit, lo
|
|
|
90
75
|
docs: docs.map((doc)=>{
|
|
91
76
|
// eslint-disable-next-line no-param-reassign
|
|
92
77
|
doc.id = doc._id;
|
|
93
|
-
return (
|
|
78
|
+
return sanitizeInternalFields(doc);
|
|
94
79
|
})
|
|
95
80
|
};
|
|
96
81
|
};
|
|
97
82
|
|
|
98
|
-
//# sourceMappingURL=
|
|
83
|
+
//# sourceMappingURL=findGlobalVersions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/findGlobalVersions.ts"],"sourcesContent":["import type { PaginateOptions } from 'mongoose'\nimport type { FindGlobalVersions } from 'payload/database'\nimport type { PayloadRequest } from 'payload/types'\n\nimport { flattenWhereToOperators } from 'payload/database'\nimport { buildVersionGlobalFields } from 'payload/versions'\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 ...withSession(this, req.transactionID),\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 offset: skip,\n options,\n page,\n pagination,\n sort,\n useEstimatedCount,\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 // eslint-disable-next-line no-param-reassign\n doc.id = doc._id\n return sanitizeInternalFields(doc)\n }),\n }\n}\n"],"names":["flattenWhereToOperators","buildVersionGlobalFields","buildSortParam","sanitizeInternalFields","withSession","findGlobalVersions","global","limit","locale","page","pagination","req","skip","sort","sortArg","where","Model","versions","versionFields","payload","globals","config","find","slug","options","transactionID","hasNearConstraint","constraints","some","prop","Object","keys","key","fields","timestamps","query","buildQuery","globalSlug","useEstimatedCount","length","paginationOptions","forceCountFn","lean","leanWithId","offset","disableIndexHints","useCustomCountFn","Promise","resolve","countDocuments","hint","_id","result","paginate","docs","JSON","parse","stringify","map","doc","id"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,uBAAuB,QAAQ,mBAAkB;AAC1D,SAASC,wBAAwB,QAAQ,mBAAkB;AAI3D,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,OAAOC,4BAA4B,wCAAuC;AAC1E,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,qBAAyC,eAAeA,mBAEnE,EACEC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,MAAM,CAAC,CAAmB,EAC1BC,IAAI,EACJC,MAAMC,OAAO,EACbC,KAAK,EACN;IAED,MAAMC,QAAQ,IAAI,CAACC,QAAQ,CAACX,OAAO;IACnC,MAAMY,gBAAgBjB,yBACpB,IAA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ACdiC,kBAAkBjC,KAAK,GAAGA;QAC1B,qEAAqE;QACrEiC,kBAAkBhB,OAAO,CAACjB,KAAK,GAAGA;QAElC,mCAAmC;QACnC,IAAIA,UAAU,GAAG;YACfiC,kBAAkB9B,UAAU,GAAG;QACjC;IACF;IAEA,MAAM0C,SAAS,MAAMpC,MAAMqC,QAAQ,CAAClB,OAAOK;IAC3C,MAAMc,OAAOC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACL,OAAOE,IAAI;IAElD,OAAO;QACL,GAAGF,MAAM;QACTE,MAAMA,KAAKI,GAAG,CAAC,CAACC;YACd,6CAA6C;YAC7CA,IAAIC,EAAE,GAAGD,IAAIR,GAAG;YAChB,OAAOhD,uBAAuBwD;QAChC;IACF;AACF,EAAC"}
|
package/dist/findOne.js
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "findOne", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return findOne;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _sanitizeInternalFields = /*#__PURE__*/ _interop_require_default(require("./utilities/sanitizeInternalFields"));
|
|
12
|
-
const _withSession = require("./withSession");
|
|
13
|
-
function _interop_require_default(obj) {
|
|
14
|
-
return obj && obj.__esModule ? obj : {
|
|
15
|
-
default: obj
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
const findOne = async function findOne({ collection, locale, req = {}, where }) {
|
|
1
|
+
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js';
|
|
2
|
+
import { withSession } from './withSession.js';
|
|
3
|
+
export const findOne = async function findOne({ collection, locale, req = {}, where }) {
|
|
19
4
|
const Model = this.collections[collection];
|
|
20
5
|
const options = {
|
|
21
|
-
...
|
|
6
|
+
...withSession(this, req.transactionID),
|
|
22
7
|
lean: true
|
|
23
8
|
};
|
|
24
9
|
const query = await Model.buildQuery({
|
|
@@ -33,8 +18,8 @@ const findOne = async function findOne({ collection, locale, req = {}, where })
|
|
|
33
18
|
let result = JSON.parse(JSON.stringify(doc));
|
|
34
19
|
// custom id type reset
|
|
35
20
|
result.id = result._id;
|
|
36
|
-
result = (
|
|
21
|
+
result = sanitizeInternalFields(result);
|
|
37
22
|
return result;
|
|
38
23
|
};
|
|
39
24
|
|
|
40
|
-
//# sourceMappingURL=
|
|
25
|
+
//# sourceMappingURL=findOne.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/findOne.ts"],"sourcesContent":["import type { MongooseQueryOptions } from 'mongoose'\nimport type { FindOne } from 'payload/database'\nimport type { PayloadRequest } from 'payload/types'\nimport type { Document } from 'payload/types'\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 ...withSession(this, req.transactionID),\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","transactionID","lean","query","buildQuery","payload","doc","result","JSON","parse","stringify","id","_id"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;","mappings":"AAOA,OAAOA,4BAA4B,wCAAuC;AAC1E,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,UAAmB,eAAeA,QAE7C,EAAEC,UAAU,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAAmB,EAAEC,KAAK,EAAE;IAEzD,MAAMC,QAAQ,IAAI,CAACC,WAAW,CAACL,WAAW;IAC1C,MAAMM,UAAgC;QACpC,GAAGR,YAAY,IAAI,EAAEI,IAAIK,aAAa,CAAC;QACvCC,MAAM;IACR;IAEA,MAAMC,QAAQ,MAAML,MAAMM,UAAU,CAAC;QACnCT;QACAU,SAAS,IAAI,CAACA,OAAO;QACrBR;IACF;IAEA,MAAMS,MAAM,MAAMR,MAAML,OAAO,CAACU,OAAO,CAAC,GAAGH;IAE3C,IAAI,CAACM,KAAK;QACR,OAAO;IACT;IAEA,IAAIC,SAAmBC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACJ;IAEjD,uBAAuB;IACvBC,OAAOI,EAAE,GAAGJ,OAAOK,GAAG;IACtBL,SAAShB,uBAAuBgB;IAEhC,OAAOA;AACT,EAAC"}
|
package/dist/findVersions.js
CHANGED
|
@@ -1,38 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return findVersions;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _database = require("payload/database");
|
|
12
|
-
const _buildSortParam = require("./queries/buildSortParam");
|
|
13
|
-
const _sanitizeInternalFields = /*#__PURE__*/ _interop_require_default(require("./utilities/sanitizeInternalFields"));
|
|
14
|
-
const _withSession = require("./withSession");
|
|
15
|
-
function _interop_require_default(obj) {
|
|
16
|
-
return obj && obj.__esModule ? obj : {
|
|
17
|
-
default: obj
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
const findVersions = async function findVersions({ collection, limit, locale, page, pagination, req = {}, skip, sort: sortArg, where }) {
|
|
1
|
+
import { flattenWhereToOperators } from 'payload/database';
|
|
2
|
+
import { buildSortParam } from './queries/buildSortParam.js';
|
|
3
|
+
import sanitizeInternalFields from './utilities/sanitizeInternalFields.js';
|
|
4
|
+
import { withSession } from './withSession.js';
|
|
5
|
+
export const findVersions = async function findVersions({ collection, limit, locale, page, pagination, req = {}, skip, sort: sortArg, where }) {
|
|
21
6
|
const Model = this.versions[collection];
|
|
22
7
|
const collectionConfig = this.payload.collections[collection].config;
|
|
23
8
|
const options = {
|
|
24
|
-
...
|
|
9
|
+
...withSession(this, req.transactionID),
|
|
25
10
|
limit,
|
|
26
11
|
skip
|
|
27
12
|
};
|
|
28
13
|
let hasNearConstraint = false;
|
|
29
14
|
if (where) {
|
|
30
|
-
const constraints =
|
|
15
|
+
const constraints = flattenWhereToOperators(where);
|
|
31
16
|
hasNearConstraint = constraints.some((prop)=>Object.keys(prop).some((key)=>key === 'near'));
|
|
32
17
|
}
|
|
33
18
|
let sort;
|
|
34
19
|
if (!hasNearConstraint) {
|
|
35
|
-
sort =
|
|
20
|
+
sort = buildSortParam({
|
|
36
21
|
config: this.payload.config,
|
|
37
22
|
fields: collectionConfig.fields,
|
|
38
23
|
locale,
|
|
@@ -88,9 +73,9 @@ const findVersions = async function findVersions({ collection, limit, locale, pa
|
|
|
88
73
|
docs: docs.map((doc)=>{
|
|
89
74
|
// eslint-disable-next-line no-param-reassign
|
|
90
75
|
doc.id = doc._id;
|
|
91
|
-
return (
|
|
76
|
+
return sanitizeInternalFields(doc);
|
|
92
77
|
})
|
|
93
78
|
};
|
|
94
79
|
};
|
|
95
80
|
|
|
96
|
-
//# sourceMappingURL=
|
|
81
|
+
//# sourceMappingURL=findVersions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/findVersions.ts"],"sourcesContent":["import type { PaginateOptions } from 'mongoose'\nimport type { FindVersions } from 'payload/database'\nimport type { PayloadRequest } from 'payload/types'\n\nimport { flattenWhereToOperators } from 'payload/database'\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 findVersions: FindVersions = async function findVersions(\n this: MongooseAdapter,\n {\n collection,\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[collection]\n const collectionConfig = this.payload.collections[collection].config\n const options = {\n ...withSession(this, req.transactionID),\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: collectionConfig.fields,\n locale,\n sort: sortArg || '-updatedAt',\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 limit,\n options,\n page,\n pagination,\n sort,\n useEstimatedCount,\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 // eslint-disable-next-line no-param-reassign\n doc.id = doc._id\n return sanitizeInternalFields(doc)\n }),\n }\n}\n"],"names":["flattenWhereToOperators","buildSortParam","sanitizeInternalFields","withSession","findVersions","collection","limit","locale","page","pagination","req","skip","sort","sortArg","where","Model","versions","collectionConfig","payload","collections","config","options","transactionID","hasNearConstraint","constraints","some","prop","Object","keys","key","fields","timestamps","query","buildQuery","useEstimatedCount","length","paginationOptions","forceCountFn","lean","leanWithId","disableIndexHints","useCustomCountFn","Promise","resolve","countDocuments","hint","_id","result","paginate","docs","JSON","parse","stringify","map","doc","id"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,uBAAuB,QAAQ,mBAAkB;AAI1D,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,OAAOC,4BAA4B,wCAAuC;AAC1E,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,eAA6B,eAAeA,aAEvD,EACEC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,MAAM,CAAC,CAAmB,EAC1BC,IAAI,EACJC,MAAMC,OAAO,EACbC,KAAK,EACN;IAED,MAAMC,QAAQ,IAAI,CAACC,QAAQ,CAACX,WAAW;IACvC,MAAMY,mBAAmB,IAAI,CAACC,OAAO,CAACC,WAAW,CAACd,WAAW,CAACe,MAAM;IACpE,MAAMC,UAAU;QACd,GAAGlB,YAAY,IAAI,EAAEO,IAAIY,aAAa,CAAC;QACvChB;QACAK;IACF;IAEA,IAAIY,oBAAoB;IAExB,IAAIT,OAAO;QACT,MAAMU,cAAcxB,wBAAwBc;QAC5CS,oBAAoBC,YAAYC,IAAI,CAAC,CAACC,OAASC,OAAOC,IAAI,CAACF,MAAMD,IAAI,CAAC,CAACI,MAAQA,QAAQ;IACzF;IAEA,IAAIjB;IACJ,IAAI,CAACW,mBAAmB;QACtBX,OAAOX,eAAe;YACpBmB,QAAQ,IAAI,CAACF,OAAO,CAACE,MAAM;YA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.d.ts
CHANGED
|
@@ -1,9 +1,34 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate.js" />
|
|
2
|
+
/// <reference types="mongoose/types/callback.js" />
|
|
3
|
+
/// <reference types="mongoose/types/collection.js" />
|
|
4
|
+
/// <reference types="mongoose/types/connection.js" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor.js" />
|
|
6
|
+
/// <reference types="mongoose/types/document.js" />
|
|
7
|
+
/// <reference types="mongoose/types/error.js" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions.js" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers.js" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares.js" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes.js" />
|
|
12
|
+
/// <reference types="mongoose/types/models.js" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions.js" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage.js" />
|
|
15
|
+
/// <reference types="mongoose/types/populate.js" />
|
|
16
|
+
/// <reference types="mongoose/types/query.js" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions.js" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes.js" />
|
|
19
|
+
/// <reference types="mongoose/types/session.js" />
|
|
20
|
+
/// <reference types="mongoose/types/types.js" />
|
|
21
|
+
/// <reference types="mongoose/types/utility.js" />
|
|
22
|
+
/// <reference types="mongoose/types/validation.js" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals.js" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype.js" />
|
|
25
|
+
/// <reference types="mongoose-paginate-v2" />
|
|
1
26
|
import type { TransactionOptions } from 'mongodb';
|
|
27
|
+
import type { MongoMemoryReplSet } from 'mongodb-memory-server';
|
|
2
28
|
import type { ClientSession, ConnectOptions, Connection } from 'mongoose';
|
|
3
|
-
import type { BaseDatabaseAdapter } from 'payload/database';
|
|
4
|
-
import type { CollectionModel, GlobalModel } from './types';
|
|
5
|
-
export type { MigrateDownArgs, MigrateUpArgs } from './types';
|
|
6
|
-
import type { DatabaseAdapterObj } from 'payload/database';
|
|
29
|
+
import type { BaseDatabaseAdapter, DatabaseAdapterObj } from 'payload/database';
|
|
30
|
+
import type { CollectionModel, GlobalModel } from './types.js';
|
|
31
|
+
export type { MigrateDownArgs, MigrateUpArgs } from './types.js';
|
|
7
32
|
export interface Args {
|
|
8
33
|
/** Set to false to disable auto-pluralization of collection names, Defaults to true */
|
|
9
34
|
autoPluralization?: boolean;
|
|
@@ -15,6 +40,10 @@ export interface Args {
|
|
|
15
40
|
/** 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 */
|
|
16
41
|
disableIndexHints?: boolean;
|
|
17
42
|
migrationDir?: string;
|
|
43
|
+
/**
|
|
44
|
+
* typed as any to avoid dependency
|
|
45
|
+
*/
|
|
46
|
+
mongoMemoryServer?: MongoMemoryReplSet;
|
|
18
47
|
transactionOptions?: TransactionOptions | false;
|
|
19
48
|
/** The URL to connect to MongoDB or false to start payload and prevent connecting */
|
|
20
49
|
url: false | string;
|
|
@@ -25,7 +54,7 @@ export type MongooseAdapter = BaseDatabaseAdapter & Args & {
|
|
|
25
54
|
};
|
|
26
55
|
connection: Connection;
|
|
27
56
|
globals: GlobalModel;
|
|
28
|
-
mongoMemoryServer:
|
|
57
|
+
mongoMemoryServer: MongoMemoryReplSet;
|
|
29
58
|
sessions: Record<number | string, ClientSession>;
|
|
30
59
|
versions: {
|
|
31
60
|
[slug: string]: CollectionModel;
|
|
@@ -38,7 +67,7 @@ declare module 'payload' {
|
|
|
38
67
|
};
|
|
39
68
|
connection: Connection;
|
|
40
69
|
globals: GlobalModel;
|
|
41
|
-
mongoMemoryServer:
|
|
70
|
+
mongoMemoryServer: MongoMemoryReplSet;
|
|
42
71
|
sessions: Record<number | string, ClientSession>;
|
|
43
72
|
transactionOptions: TransactionOptions;
|
|
44
73
|
versions: {
|
|
@@ -46,5 +75,5 @@ declare module 'payload' {
|
|
|
46
75
|
};
|
|
47
76
|
}
|
|
48
77
|
}
|
|
49
|
-
export declare function mongooseAdapter({ autoPluralization, connectOptions, disableIndexHints, migrationDir: migrationDirArg, transactionOptions, url, }: Args): DatabaseAdapterObj;
|
|
78
|
+
export declare function mongooseAdapter({ autoPluralization, connectOptions, disableIndexHints, migrationDir: migrationDirArg, mongoMemoryServer, transactionOptions, url, }: Args): DatabaseAdapterObj;
|
|
50
79
|
//# sourceMappingURL=index.d.ts.map
|
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,kBAAkB,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAEzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAEzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAO/E,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AA4B9D,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAEhE,MAAM,WAAW,IAAI;IACnB,uFAAuF;IACvF,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,kCAAkC;IA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