@graffy/pg 0.19.1-alpha.1 → 0.19.1-alpha.2
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/Db.d.ts +3 -2
- package/filter/getAst.js +3 -1
- package/index.d.ts +1 -1
- package/index.js +11 -8
- package/package.json +3 -3
- package/sql/clauses.js +1 -1
package/Db.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export default class Db {
|
|
2
|
+
client: any;
|
|
2
3
|
constructor(connection: any);
|
|
3
|
-
query(sql: any, tableOptions
|
|
4
|
+
query(sql: any, tableOptions?: any): Promise<any>;
|
|
4
5
|
readSql(sql: any, tableOptions: any): Promise<any>;
|
|
5
6
|
writeSql(sql: any, tableOptions: any): Promise<any>;
|
|
6
|
-
ensureSchema(tableOptions: any, typeOids
|
|
7
|
+
ensureSchema(tableOptions: any, typeOids?: any): Promise<void>;
|
|
7
8
|
read(rootQuery: any, tableOptions: any): Promise<{
|
|
8
9
|
key: Uint8Array<ArrayBuffer>;
|
|
9
10
|
end: Uint8Array<ArrayBuffer>;
|
package/filter/getAst.js
CHANGED
|
@@ -134,7 +134,9 @@ function simplify(node) {
|
|
|
134
134
|
if (change) {
|
|
135
135
|
node[1] = [
|
|
136
136
|
...noneq,
|
|
137
|
-
...Object.entries(eqmap).map(([prop, val]) => val.length > 1
|
|
137
|
+
...Object.entries(eqmap).map(([prop, val]) => val.length > 1
|
|
138
|
+
? ['$in', prop, val]
|
|
139
|
+
: ['$eq', prop, val[0]]),
|
|
138
140
|
];
|
|
139
141
|
}
|
|
140
142
|
}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -16,19 +16,22 @@ import Db from "./Db.js";
|
|
|
16
16
|
* @param {string} parentName
|
|
17
17
|
* @returns {TableOpts}
|
|
18
18
|
*/
|
|
19
|
-
function getTableOpts(name, { table, idCol, verCol, joins, schema, verDefault } = {}, parentName = null) {
|
|
19
|
+
function getTableOpts(name, { table, idCol, verCol, joins, schema, verDefault, } = {}, parentName = null) {
|
|
20
20
|
const tableName = table || name;
|
|
21
21
|
return {
|
|
22
22
|
table: table || name,
|
|
23
23
|
idCol: idCol || 'id',
|
|
24
24
|
verCol: verCol || 'updatedAt',
|
|
25
|
-
joins: Object.fromEntries(Object.entries(joins || {}).map(([joinName,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
joins: Object.fromEntries(Object.entries(joins || {}).map(([joinName, joinVal]) => {
|
|
26
|
+
const { refCol = parentName, ...joinOptions } = joinVal;
|
|
27
|
+
return [
|
|
28
|
+
joinName,
|
|
29
|
+
{
|
|
30
|
+
refCol,
|
|
31
|
+
...getTableOpts(joinName, joinOptions, tableName),
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
})),
|
|
32
35
|
schema,
|
|
33
36
|
verDefault,
|
|
34
37
|
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graffy/pg",
|
|
3
3
|
"description": "The standard Postgres module for Graffy. Each instance this module mounts a Postgres table as a Graffy subtree.",
|
|
4
4
|
"author": "aravind (https://github.com/aravindet)",
|
|
5
|
-
"version": "0.19.1-alpha.
|
|
5
|
+
"version": "0.19.1-alpha.2",
|
|
6
6
|
"main": "./cjs/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"sql-formatter": "^15.7.
|
|
25
|
-
"@graffy/common": "0.19.1-alpha.
|
|
24
|
+
"sql-formatter": "^15.7.4",
|
|
25
|
+
"@graffy/common": "0.19.1-alpha.2",
|
|
26
26
|
"sql-template-tag": "^5.2.1",
|
|
27
27
|
"debug": "^4.4.3"
|
|
28
28
|
},
|
package/sql/clauses.js
CHANGED
|
@@ -213,7 +213,7 @@ function stripAttributes(object) {
|
|
|
213
213
|
if (Array.isArray(object)) {
|
|
214
214
|
return object.map((item) => stripAttributes(item));
|
|
215
215
|
}
|
|
216
|
-
return Object.entries(object).reduce((
|
|
216
|
+
return Object.entries(object).reduce((out, [key, val]) => {
|
|
217
217
|
if (key === '$put' || val === null)
|
|
218
218
|
return out;
|
|
219
219
|
if (out === null)
|