drizzle-orm 0.10.42 → 0.10.43
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/columns/types/pgJsonb.js +1 -1
- package/columns/types/pgText.js +1 -1
- package/columns/types/pgVarChar.js +1 -1
- package/package.json +1 -1
- package/test.d.ts +1 -0
- package/test.js +103 -103
package/columns/types/pgJsonb.js
CHANGED
|
@@ -10,7 +10,7 @@ class PgJsonb extends columnType_1.default {
|
|
|
10
10
|
super();
|
|
11
11
|
this.getDbName = () => this.dbName;
|
|
12
12
|
// public insertStrategy = (value: TCodeType): string => `'${JSON.stringify(value).replace(/'/g, "''")}'::jsonb`;
|
|
13
|
-
this.insertStrategy = (value) => `${JSON.stringify(value)
|
|
13
|
+
this.insertStrategy = (value) => `${JSON.stringify(value)}`;
|
|
14
14
|
this.dbName = 'JSONB';
|
|
15
15
|
}
|
|
16
16
|
selectStrategy(value) {
|
package/columns/types/pgText.js
CHANGED
|
@@ -8,7 +8,7 @@ class PgText extends columnType_1.default {
|
|
|
8
8
|
constructor() {
|
|
9
9
|
super();
|
|
10
10
|
this.getDbName = () => this.dbName;
|
|
11
|
-
this.insertStrategy = (value) => `${value
|
|
11
|
+
this.insertStrategy = (value) => `${value}`;
|
|
12
12
|
this.dbName = 'TEXT';
|
|
13
13
|
}
|
|
14
14
|
selectStrategy(value) {
|
|
@@ -8,7 +8,7 @@ class PgVarChar extends columnType_1.default {
|
|
|
8
8
|
constructor(size) {
|
|
9
9
|
super();
|
|
10
10
|
this.getDbName = () => this.dbName;
|
|
11
|
-
this.insertStrategy = (value) => `${value
|
|
11
|
+
this.insertStrategy = (value) => `${value}`;
|
|
12
12
|
this.size = size;
|
|
13
13
|
if (size) {
|
|
14
14
|
this.dbName = `character varying(${size})`;
|
package/package.json
CHANGED
package/test.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/test.js
CHANGED
|
@@ -1,104 +1,104 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
//
|
|
83
|
-
//
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
//
|
|
90
|
-
//
|
|
91
|
-
//
|
|
92
|
-
//
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const dbConnector_1 = __importDefault(require("./db/dbConnector"));
|
|
7
|
+
const session_1 = require("./db/session");
|
|
8
|
+
const usersTable_1 = __importDefault(require("./docs/tables/usersTable"));
|
|
9
|
+
class KnexSession extends session_1.ISession {
|
|
10
|
+
execute(query, values) {
|
|
11
|
+
console.log(query);
|
|
12
|
+
console.log(values);
|
|
13
|
+
return { rows: [] };
|
|
14
|
+
}
|
|
15
|
+
parametrized(num) {
|
|
16
|
+
return `${num}?`;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
(async () => {
|
|
20
|
+
try {
|
|
21
|
+
const db = await new dbConnector_1.default()
|
|
22
|
+
.connectionString('postgresql://postgres@127.0.0.1/migrator')
|
|
23
|
+
.connect();
|
|
24
|
+
// const db = new DB(new KnexSession());
|
|
25
|
+
// db.useLogger(new ConsoleLogger());
|
|
26
|
+
const usersTable = new usersTable_1.default(db);
|
|
27
|
+
// await usersTable.select().where(or([
|
|
28
|
+
// and([eq(usersTable.role, 'bar'), less(usersTable.phone, 'd')]),
|
|
29
|
+
// eq(usersTable.role, 'bar'),
|
|
30
|
+
// greater(usersTable.decimalField, 1),
|
|
31
|
+
// ])).execute();
|
|
32
|
+
// await usersTable.delete().where(or([
|
|
33
|
+
// and([eq(usersTable.role, 'bar'), less(usersTable.phone, 'd')]),
|
|
34
|
+
// eq(usersTable.role, 'bar'),
|
|
35
|
+
// greater(usersTable.decimalField, 1),
|
|
36
|
+
// ])).execute();
|
|
37
|
+
// await usersTable.update().where(or([
|
|
38
|
+
// and([eq(usersTable.role, 'bar'), less(usersTable.phone, 'd')]),
|
|
39
|
+
// eq(usersTable.role, 'bar'),
|
|
40
|
+
// greater(usersTable.decimalField, 1),
|
|
41
|
+
// ])).set({
|
|
42
|
+
// isArchived: false,
|
|
43
|
+
// role: 'bar',
|
|
44
|
+
// }).execute();
|
|
45
|
+
await usersTable.insert({
|
|
46
|
+
isArchived: false,
|
|
47
|
+
role: 'bar',
|
|
48
|
+
decimalField: 12,
|
|
49
|
+
phone: ' tedss\'t',
|
|
50
|
+
media: [' tes\'t', ' t\'es\'t'],
|
|
51
|
+
createdAt: new Date(),
|
|
52
|
+
}).execute();
|
|
53
|
+
// drizzle.migrator(db).migrate({ migrationFolder: 'drizzle' });
|
|
54
|
+
// type g = ReturnType<typeof usersTable.updatedAt.getColumnType>['codeType'];
|
|
55
|
+
// type f = ExtractColumnType<typeof usersTable.updatedAt>;
|
|
56
|
+
// type f1 = ExtractColumnType1<f>;
|
|
57
|
+
// const citiesTable = new CitiesTable(db);
|
|
58
|
+
// await usersTable.insert({
|
|
59
|
+
// });
|
|
60
|
+
// const res = await citiesTable.update()
|
|
61
|
+
// // .groupBy((table, join1, join2, join3) => [table.id, join1.id, join1.phone])
|
|
62
|
+
// .where(eq(citiesTable.location, 'YR'))
|
|
63
|
+
// .set({
|
|
64
|
+
// metadata: [{
|
|
65
|
+
// fallback_image: true,
|
|
66
|
+
// team_image: 'https://files.slack.com/files-pri/T016CCC3FE3-F03461UR9M5/clinic_team_photo_1.jpg?pub_secret=560c098bfb',
|
|
67
|
+
// image_alt_text: 'Generic Physiotherapy Clinic image 1',
|
|
68
|
+
// logo: '',
|
|
69
|
+
// logo_alt_text: ''
|
|
70
|
+
// }],
|
|
71
|
+
// })
|
|
72
|
+
// // .leftJoin(CitiesTable, UsersTable, (table) => table.userId, (table) => table.id)
|
|
73
|
+
// // .leftJoin(UsersTable, UsersTable, (table) => table.id, (table) => table.id)
|
|
74
|
+
// .execute();
|
|
75
|
+
// console.log(res);
|
|
76
|
+
// const ser = new MigrationSerializer();
|
|
77
|
+
// const res = ser.generate([usersTable as AbstractTable<UsersTable>], []);
|
|
78
|
+
// console.log(JSON.stringify(res, null, 2));
|
|
79
|
+
// const f = {
|
|
80
|
+
// id: count(usersTable.id),
|
|
81
|
+
// };
|
|
82
|
+
// type d = ExtractModel<typeof f>;
|
|
83
|
+
// const res = await usersTable.select()
|
|
84
|
+
// .leftJoin(UsersTable, (table) => table.id, (table) => table.id)
|
|
85
|
+
// .leftJoin(UsersTable, CitiesTable, (table) => table.id, (table) => table.id)
|
|
86
|
+
// .execute();
|
|
87
|
+
// const res = await usersTable.select()
|
|
88
|
+
// // .groupBy((table, join1, join2, join3) => [table.id, join1.id, join1.phone])
|
|
89
|
+
// .leftJoin(UsersTable, (table) => table.foundationDate, (table) => table.id)
|
|
90
|
+
// .leftJoin(UsersTable, UsersTable, (table) => table.role, (table) => table.id)
|
|
91
|
+
// .leftJoin(UsersTable, UsersTable, (table) => table.role, (table) => table.id)
|
|
92
|
+
// // .groupBy({
|
|
93
|
+
// // usersTable: usersTable.id,
|
|
94
|
+
// // firstJoin: [usersTable.id],
|
|
95
|
+
// // secondJoin: usersTable.id,
|
|
96
|
+
// // thirdJoin: usersTable.id,
|
|
97
|
+
// // })
|
|
98
|
+
// .execute();
|
|
99
|
+
// console.log(res);
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
console.log(e);
|
|
103
|
+
}
|
|
104
|
+
})();
|