drizzle-orm 0.9.18 → 0.9.19

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.
@@ -6,6 +6,9 @@ class Const extends where_1.default {
6
6
  constructor(value) {
7
7
  super();
8
8
  this.toQuery = () => {
9
+ if (this.value instanceof Date) {
10
+ return `'${this.value.toISOString()}'`;
11
+ }
9
12
  if (ecranate_1.shouldEcranate(this.value)) {
10
13
  return `'${this.value.toString()}'`;
11
14
  }
@@ -9,6 +9,9 @@ class ConstArray extends where_1.default {
9
9
  const finalArray = [];
10
10
  for (let i = 0; i < this.values.length; i += 1) {
11
11
  const value = this.values[i];
12
+ if (value instanceof Date) {
13
+ return `'${value.toISOString()}'`;
14
+ }
12
15
  if (ecranate_1.shouldEcranate(value)) {
13
16
  finalArray.push(`'${value.toString()}'`);
14
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-orm",
3
- "version": "0.9.18",
3
+ "version": "0.9.19",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/test.js CHANGED
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const _1 = require(".");
4
+ const builders_1 = require("./builders");
5
+ const citiesTable_1 = require("./docs/tables/citiesTable");
6
+ const usersTable_1 = require("./docs/tables/usersTable");
7
+ const consoleLogger_1 = require("./logger/consoleLogger");
4
8
  // import { Pool } from 'pg';
5
9
  // import { DB } from '.';
6
10
  // import { DB, DbConnector } from '.';
@@ -18,8 +22,9 @@ const fromTypeFile = (filepath) => {
18
22
  (async () => {
19
23
  try {
20
24
  const db = await new _1.DbConnector()
21
- .connectionString('postgresql://postgres@127.0.0.1/drizzle-docs')
25
+ .connectionString('postgres://postgres:c59cdfc8a440f8b76c460686f9657f14@174.138.4.190:28882/db_small')
22
26
  .connect();
27
+ db.useLogger(new consoleLogger_1.default());
23
28
  // const serializer = new MigrationSerializer();
24
29
  // const res = await serializer.fromDatabase(db);
25
30
  // fs.writeFileSync('introspected.json', JSON.stringify(res, null, 2), 'utf8');
@@ -27,7 +32,7 @@ const fromTypeFile = (filepath) => {
27
32
  // const d = db.create(UsersTable) as unknown as AbstractTable<any>;
28
33
  // const f = ser.generate([d], []);
29
34
  // console.log(JSON.stringify(f, null, 2));
30
- await _1.drizzle.migrator(db).migrate({ migrationFolder: 'src/drizzle.config.yaml' });
35
+ // await drizzle.migrator(db).migrate({ migrationFolder: 'src/drizzle.config.yaml' });
31
36
  // drizzle.migrator(db).migrate({ migrationFolder: '' });
32
37
  // const typesFileNames = fs.readdirSync('/Users/andrewsherman/IdeaProjects/datalayer-orm/src/examples/types');
33
38
  // typesFileNames.forEach((filename) => {
@@ -36,8 +41,9 @@ const fromTypeFile = (filepath) => {
36
41
  // console.log(typeValues);
37
42
  // // console.log(Object.values(typeValues));
38
43
  // });
39
- // // const usersTest = new UsersTest();
40
- // // await usersTest.execute();
44
+ const usersTable = new usersTable_1.default(db);
45
+ const citiesTable = new citiesTable_1.default(db);
46
+ await usersTable.select().where(builders_1.greater(usersTable.createdAtWithTimezone, new Date())).execute();
41
47
  // const db = await new DbConnector()
42
48
  // .connectionString('postgresql://postgres@127.0.0.1/drizzle')
43
49
  // .connect();
@@ -58,19 +64,55 @@ const fromTypeFile = (filepath) => {
58
64
  // );
59
65
  // type f = ExtractModel<typeof objectRes1>;
60
66
  // type d1 = ExtractModel<UsersTable>;
61
- // const f = await usersTable.select()
62
- // .fieldsv2({
63
- // usersCount: count(usersTable.id),
64
- // sumNumber: sum(usersTable.phone),
65
- // role: usersTable.role,
67
+ // const dff = usersTable.phone;
68
+ // const f = usersTable.select()
69
+ // .partial({
70
+ // // usersCount: usersTable.id,
71
+ // sumNumber: usersTable.phone,
66
72
  // });
73
+ // const f = usersTable.select({
74
+ // usersCount: usersTable.id,
75
+ // sumNumber: usersTable.phone,
76
+ // })
77
+ // .limit(2)
78
+ // .offset(2)
79
+ // .all();
80
+ // Done: provide partial interface + partial objects to each join inside and use in each execute mapper
81
+ // Add possibility tp join on another table -> https://www.postgresqltutorial.com/postgresql-inner-join/
82
+ // const f1 = await usersTable.select({
83
+ // usersCount: usersTable.id,
84
+ // sumNumber: usersTable.phone,
85
+ // })
86
+ // .leftJoin(CitiesTable,
87
+ // (table) => table.id,
88
+ // (cities) => cities.userId,
89
+ // {
90
+ // cityId: citiesTable.id,
91
+ // cityLocation: citiesTable.location,
92
+ // })
93
+ // .leftJoin(CitiesTable,
94
+ // (table: CitiesTable) => table.id,
95
+ // (cities) => cities.userId)
96
+ // .execute();
97
+ // f1.map((user, city, city1) => {
98
+ // });
99
+ // const f = usersTable.select().testTypes();
100
+ // const rg = {
101
+ // // usersCount: usersTable.id,
102
+ // sumNumber: usersTable.phone,
103
+ // };
104
+ // const f = await usersTable.select({
105
+ // usersCount: usersTable.id,
106
+ // sumNumber: usersTable.phone,
107
+ // }).all();
108
+ // console.log(typeof f);
67
109
  // const objectRes1 = {
68
- // idid: usersTable.id,
69
- // pisun: usersTable.phone,
70
- // vau: usersTable.role,
110
+ // usersCount: usersTable.id,
111
+ // sumNumber: usersTable.phone,
71
112
  // };
72
- // type fd = ExtractModel<typeof objectRes1>;
113
+ // type fd = ExtractModel<typeof f>;
73
114
  // const g = await usersTable.select().execute();
115
+ // type fd = ExtractModel<typeof g>;
74
116
  // if (res.isLeft()) {
75
117
  // console.log(res.value.reason);
76
118
  // } else {