@payloadcms/db-sqlite 3.23.0-canary.e847e12 → 3.23.0-canary.ec17695
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"countDistinct.d.ts","sourceRoot":"","sources":["../src/countDistinct.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,YAAY,CAAA;AAE9D,eAAO,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"countDistinct.d.ts","sourceRoot":"","sources":["../src/countDistinct.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,YAAY,CAAA;AAE9D,eAAO,MAAM,aAAa,EAAE,aAwB3B,CAAA"}
|
package/dist/countDistinct.js
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import { chainMethods } from '@payloadcms/drizzle';
|
|
2
|
-
import { count
|
|
2
|
+
import { count } from 'drizzle-orm';
|
|
3
3
|
export const countDistinct = async function countDistinct({ db, joins, tableName, where }) {
|
|
4
4
|
const chainedMethods = [];
|
|
5
|
-
|
|
6
|
-
const visitedPaths = new Set([]);
|
|
7
|
-
let useDistinct = false;
|
|
8
|
-
joins.forEach(({ condition, queryPath, table })=>{
|
|
9
|
-
if (!useDistinct && queryPath) {
|
|
10
|
-
if (visitedPaths.has(queryPath)) {
|
|
11
|
-
useDistinct = true;
|
|
12
|
-
} else {
|
|
13
|
-
visitedPaths.add(queryPath);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
5
|
+
joins.forEach(({ condition, table })=>{
|
|
16
6
|
chainedMethods.push({
|
|
17
7
|
args: [
|
|
18
8
|
table,
|
|
@@ -24,7 +14,7 @@ export const countDistinct = async function countDistinct({ db, joins, tableName
|
|
|
24
14
|
const countResult = await chainMethods({
|
|
25
15
|
methods: chainedMethods,
|
|
26
16
|
query: db.select({
|
|
27
|
-
count:
|
|
17
|
+
count: count()
|
|
28
18
|
}).from(this.tables[tableName]).where(where)
|
|
29
19
|
});
|
|
30
20
|
return Number(countResult[0].count);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/countDistinct.ts"],"sourcesContent":["import type { ChainedMethods } from '@payloadcms/drizzle/types'\n\nimport { chainMethods } from '@payloadcms/drizzle'\nimport { count
|
|
1
|
+
{"version":3,"sources":["../src/countDistinct.ts"],"sourcesContent":["import type { ChainedMethods } from '@payloadcms/drizzle/types'\n\nimport { chainMethods } from '@payloadcms/drizzle'\nimport { count } from 'drizzle-orm'\n\nimport type { CountDistinct, SQLiteAdapter } from './types.js'\n\nexport const countDistinct: CountDistinct = async function countDistinct(\n this: SQLiteAdapter,\n { db, joins, tableName, where },\n) {\n const chainedMethods: ChainedMethods = []\n\n joins.forEach(({ condition, table }) => {\n chainedMethods.push({\n args: [table, condition],\n method: 'leftJoin',\n })\n })\n\n const countResult = await chainMethods({\n methods: chainedMethods,\n query: db\n .select({\n count: count(),\n })\n .from(this.tables[tableName])\n .where(where),\n })\n\n return Number(countResult[0].count)\n}\n"],"names":["chainMethods","count","countDistinct","db","joins","tableName","where","chainedMethods","forEach","condition","table","push","args","method","countResult","methods","query","select","from","tables","Number"],"mappings":"AAEA,SAASA,YAAY,QAAQ,sBAAqB;AAClD,SAASC,KAAK,QAAQ,cAAa;AAInC,OAAO,MAAMC,gBAA+B,eAAeA,cAEzD,EAAEC,EAAE,EAAEC,KAAK,EAAEC,SAAS,EAAEC,KAAK,EAAE;IAE/B,MAAMC,iBAAiC,EAAE;IAEzCH,MAAMI,OAAO,CAAC,CAAC,EAAEC,SAAS,EAAEC,KAAK,EAAE;QACjCH,eAAeI,IAAI,CAAC;YAClBC,MAAM;gBAACF;gBAAOD;aAAU;YACxBI,QAAQ;QACV;IACF;IAEA,MAAMC,cAAc,MAAMd,aAAa;QACrCe,SAASR;QACTS,OAAOb,GACJc,MAAM,CAAC;YACNhB,OAAOA;QACT,GACCiB,IAAI,CAAC,IAAI,CAACC,MAAM,CAACd,UAAU,EAC3BC,KAAK,CAACA;IACX;IAEA,OAAOc,OAAON,WAAW,CAAC,EAAE,CAACb,KAAK;AACpC,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/db-sqlite",
|
|
3
|
-
"version": "3.23.0-canary.
|
|
3
|
+
"version": "3.23.0-canary.ec17695",
|
|
4
4
|
"description": "The officially supported SQLite database adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -69,16 +69,16 @@
|
|
|
69
69
|
"prompts": "2.4.2",
|
|
70
70
|
"to-snake-case": "1.0.0",
|
|
71
71
|
"uuid": "9.0.0",
|
|
72
|
-
"@payloadcms/drizzle": "3.23.0-canary.
|
|
72
|
+
"@payloadcms/drizzle": "3.23.0-canary.ec17695"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@types/pg": "8.10.2",
|
|
76
76
|
"@types/to-snake-case": "1.0.0",
|
|
77
77
|
"@payloadcms/eslint-config": "3.9.0",
|
|
78
|
-
"payload": "3.23.0-canary.
|
|
78
|
+
"payload": "3.23.0-canary.ec17695"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
|
-
"payload": "3.23.0-canary.
|
|
81
|
+
"payload": "3.23.0-canary.ec17695"
|
|
82
82
|
},
|
|
83
83
|
"scripts": {
|
|
84
84
|
"build": "pnpm build:swc && pnpm build:types",
|