drizzle-orm 0.10.0 → 0.10.4
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/column.d.ts +5 -5
- package/columns/types/pgInteger.d.ts +1 -1
- package/columns/types/pgInteger.js +1 -1
- package/columns/types/pgSerial.d.ts +1 -1
- package/columns/types/pgSerial.js +1 -1
- package/columns/types/pgSmallInt.d.ts +1 -1
- package/columns/types/pgSmallInt.js +1 -1
- package/data/tables/citiesTable.d.ts +14 -0
- package/data/tables/citiesTable.js +17 -0
- package/data/tables/userGroupsTable.d.ts +7 -0
- package/data/tables/userGroupsTable.js +15 -0
- package/data/tables/usersTable.d.ts +16 -0
- package/data/tables/usersTable.js +31 -0
- package/data/tables/usersToUserGroups.d.ts +7 -0
- package/data/tables/usersToUserGroups.js +17 -0
- package/data/types/rolesType.d.ts +1 -0
- package/data/types/rolesType.js +6 -0
- package/migrator/migrator.js +10 -2
- package/package.json +1 -1
- package/serializer/serializer.js +14 -1
- package/tables/abstractTable.d.ts +2 -1
- package/tables/abstractTable.js +1 -1
- package/test.js +72 -5
package/columns/column.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare abstract class AbstractColumn<T extends ColumnType, TNullable ext
|
|
|
19
19
|
protected columnType: T;
|
|
20
20
|
protected columnName: string;
|
|
21
21
|
protected defaultParam: any;
|
|
22
|
-
protected referenced: AbstractColumn<T, boolean, boolean>;
|
|
22
|
+
protected referenced: AbstractColumn<T, boolean, boolean, TParent>;
|
|
23
23
|
constructor(parent: TParent, columnName: string, columnType: T);
|
|
24
24
|
getOnDelete: () => string | undefined;
|
|
25
25
|
getOnUpdate: () => string | undefined;
|
|
@@ -28,16 +28,16 @@ export declare abstract class AbstractColumn<T extends ColumnType, TNullable ext
|
|
|
28
28
|
getParentName: () => string;
|
|
29
29
|
abstract foreignKey<ITable extends AbstractTable<ITable>>(table: {
|
|
30
30
|
new (db: DB): ITable;
|
|
31
|
-
}, callback: (table: ITable) => AbstractColumn<T, boolean, boolean>, onConstraint: {
|
|
31
|
+
}, callback: (table: ITable) => AbstractColumn<T, boolean, boolean, TParent>, onConstraint: {
|
|
32
32
|
onDelete?: 'CASCADE' | 'RESTRICT' | 'SET NULL' | 'SET DEFAULT';
|
|
33
33
|
onUpdate?: 'CASCADE' | 'RESTRICT' | 'SET NULL' | 'SET DEFAULT';
|
|
34
34
|
}): AbstractColumn<T, TNullable, TAutoIncrement>;
|
|
35
35
|
defaultValue: (value: ExtractColumnType<T>) => this;
|
|
36
|
-
abstract primaryKey(): AbstractColumn<T, boolean, boolean>;
|
|
36
|
+
abstract primaryKey(): AbstractColumn<T, boolean, boolean, TParent>;
|
|
37
37
|
unique: () => this;
|
|
38
|
-
abstract notNull(): AbstractColumn<T, boolean, boolean>;
|
|
38
|
+
abstract notNull(): AbstractColumn<T, boolean, boolean, TParent>;
|
|
39
39
|
getColumnName: () => string;
|
|
40
|
-
getReferenced: () => AbstractColumn<T, boolean, boolean>;
|
|
40
|
+
getReferenced: () => AbstractColumn<T, boolean, boolean, TParent>;
|
|
41
41
|
getColumnType: () => T;
|
|
42
42
|
getDefaultValue: () => any;
|
|
43
43
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import AbstractTable from '../../tables/abstractTable';
|
|
2
|
+
interface CityMeta {
|
|
3
|
+
population: number;
|
|
4
|
+
connection: string;
|
|
5
|
+
}
|
|
6
|
+
export default class CitiesTable extends AbstractTable<CitiesTable> {
|
|
7
|
+
id: import("../..").Column<import("../../columns/types/pgSerial").default, true, true, this>;
|
|
8
|
+
foundationDate: import("../..").Column<import("../..").PgTimestamp, false, false, this>;
|
|
9
|
+
location: import("../..").Column<import("../..").PgVarChar, true, false, this>;
|
|
10
|
+
userId: import("../..").Column<import("../..").PgInteger, true, false, this>;
|
|
11
|
+
metadata: import("../..").Column<import("../..").PgJsonb<CityMeta>, true, false, this>;
|
|
12
|
+
tableName(): string;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const abstractTable_1 = require("../../tables/abstractTable");
|
|
4
|
+
class CitiesTable extends abstractTable_1.default {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.id = this.serial('id').primaryKey();
|
|
8
|
+
this.foundationDate = this.timestamp('name').notNull();
|
|
9
|
+
this.location = this.varchar('page', { size: 256 });
|
|
10
|
+
this.userId = this.int('user_id').foreignKey(CitiesTable, (table) => table.id, { onUpdate: 'CASCADE' });
|
|
11
|
+
this.metadata = this.jsonb('metadata');
|
|
12
|
+
}
|
|
13
|
+
tableName() {
|
|
14
|
+
return 'cities';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.default = CitiesTable;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import AbstractTable from '../../tables/abstractTable';
|
|
2
|
+
export default class UserGroupsTable extends AbstractTable<UserGroupsTable> {
|
|
3
|
+
id: import("../..").Column<import("../../columns/types/pgSerial").default, true, true, this>;
|
|
4
|
+
name: import("../..").Column<import("../..").PgVarChar, true, false, this>;
|
|
5
|
+
description: import("../..").Column<import("../..").PgVarChar, true, false, this>;
|
|
6
|
+
tableName(): string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const abstractTable_1 = require("../../tables/abstractTable");
|
|
4
|
+
class UserGroupsTable extends abstractTable_1.default {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.id = this.serial('id').primaryKey();
|
|
8
|
+
this.name = this.varchar('name');
|
|
9
|
+
this.description = this.varchar('description');
|
|
10
|
+
}
|
|
11
|
+
tableName() {
|
|
12
|
+
return 'user_groups';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.default = UserGroupsTable;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import AbstractTable from '../../tables/abstractTable';
|
|
2
|
+
export declare const rolesEnum: import("../../types/type").default<"user" | "guest" | "admin">;
|
|
3
|
+
export default class UsersTable extends AbstractTable<UsersTable> {
|
|
4
|
+
id: import("../..").Column<import("../../columns/types/pgSerial").default, true, true, this>;
|
|
5
|
+
fullName: import("../..").Column<import("../..").PgText, true, false, this>;
|
|
6
|
+
phone: import("../..").Column<import("../..").PgVarChar, true, false, this>;
|
|
7
|
+
media: import("../..").Column<import("../..").PgJsonb<string[]>, true, false, this>;
|
|
8
|
+
decimalField: import("../..").Column<import("../..").PgBigDecimal, false, false, this>;
|
|
9
|
+
bigIntField: import("../..").Column<import("../..").PgBigInt, true, true, this>;
|
|
10
|
+
createdAt: import("../..").Column<import("../..").PgTimestamp, false, false, this>;
|
|
11
|
+
createdAtWithTimezone: import("../..").Column<import("../../columns/types/pgTimestamptz").default, true, false, this>;
|
|
12
|
+
isArchived: import("../..").Column<import("../..").PgBoolean, true, false, this>;
|
|
13
|
+
phoneFullNameIndex: import("../../indexes/tableIndex").default;
|
|
14
|
+
phoneIndex: import("../../indexes/tableIndex").default;
|
|
15
|
+
tableName(): string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rolesEnum = void 0;
|
|
4
|
+
/* eslint-disable max-classes-per-file */
|
|
5
|
+
// import { Defaults } from '../../columns/column';
|
|
6
|
+
const abstractTable_1 = require("../../tables/abstractTable");
|
|
7
|
+
const type_1 = require("../../types/type");
|
|
8
|
+
// import { rolesEnum } from '../types/rolesType';
|
|
9
|
+
exports.rolesEnum = type_1.createEnum({ alias: 'test-enum', values: ['user', 'guest', 'admin'] });
|
|
10
|
+
class UsersTable extends abstractTable_1.default {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.id = this.serial('id').primaryKey();
|
|
14
|
+
this.fullName = this.text('full_name');
|
|
15
|
+
this.phone = this.varchar('phone', { size: 256 });
|
|
16
|
+
this.media = this.jsonb('media');
|
|
17
|
+
this.decimalField = this.decimal('test', { precision: 100, scale: 2 }).notNull();
|
|
18
|
+
this.bigIntField = this.bigint('test1', 'max_bytes_53');
|
|
19
|
+
// public role = this.type(rolesEnum, 'name_in_table', { notNull: true });
|
|
20
|
+
this.createdAt = this.timestamp('created_at').notNull();
|
|
21
|
+
this.createdAtWithTimezone = this.timestamptz('created_at_time_zone');
|
|
22
|
+
// public updatedAt = this.timestamp('updated_at').defaultValue(Defaults.CURRENT_TIMESTAMP);
|
|
23
|
+
this.isArchived = this.bool('is_archived').defaultValue(false);
|
|
24
|
+
this.phoneFullNameIndex = this.index([this.phone, this.fullName]);
|
|
25
|
+
this.phoneIndex = this.uniqueIndex(this.phone);
|
|
26
|
+
}
|
|
27
|
+
tableName() {
|
|
28
|
+
return 'users';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.default = UsersTable;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import AbstractTable from '../../tables/abstractTable';
|
|
2
|
+
export default class UsersToUserGroupsTable extends AbstractTable<UsersToUserGroupsTable> {
|
|
3
|
+
groupId: import("../..").Column<import("../..").PgInteger, true, false, this>;
|
|
4
|
+
userId: import("../..").Column<import("../..").PgInteger, true, false, this>;
|
|
5
|
+
manyToManyIndex: import("../../indexes/tableIndex").default;
|
|
6
|
+
tableName(): string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const abstractTable_1 = require("../../tables/abstractTable");
|
|
4
|
+
const userGroupsTable_1 = require("./userGroupsTable");
|
|
5
|
+
const usersTable_1 = require("./usersTable");
|
|
6
|
+
class UsersToUserGroupsTable extends abstractTable_1.default {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.groupId = this.int('city_id').foreignKey(userGroupsTable_1.default, (table) => table.id, { onDelete: 'CASCADE' });
|
|
10
|
+
this.userId = this.int('user_id').foreignKey(usersTable_1.default, (table) => table.id, { onDelete: 'CASCADE' });
|
|
11
|
+
this.manyToManyIndex = this.index([this.groupId, this.userId]);
|
|
12
|
+
}
|
|
13
|
+
tableName() {
|
|
14
|
+
return 'users_to_user_groups';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.default = UsersToUserGroupsTable;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const rolesEnum: import("../../types/type").default<"foo" | "bar" | "baz">;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rolesEnum = void 0;
|
|
4
|
+
const type_1 = require("../../types/type");
|
|
5
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
6
|
+
exports.rolesEnum = type_1.createEnum({ alias: 'test-enum', values: ['foo', 'bar', 'baz'] });
|
package/migrator/migrator.js
CHANGED
|
@@ -22,7 +22,7 @@ class Migrator {
|
|
|
22
22
|
const entry = split.trim().split(':');
|
|
23
23
|
const key = entry[0];
|
|
24
24
|
const value = entry[1].trim().replace(/['"]+/g, '');
|
|
25
|
-
if (key === '
|
|
25
|
+
if (key === 'migrationRootFolder') {
|
|
26
26
|
// proceed value
|
|
27
27
|
migrationFolderTo = value;
|
|
28
28
|
}
|
|
@@ -48,7 +48,15 @@ class Migrator {
|
|
|
48
48
|
const migrationFiles = fs.readdirSync(`${migrationFolderTo}/${migrationFolder}`);
|
|
49
49
|
const migrationFile = migrationFiles.filter((file) => file === 'migration.sql')[0];
|
|
50
50
|
const query = fs.readFileSync(`${migrationFolderTo}/${migrationFolder}/${migrationFile}`).toString();
|
|
51
|
-
const
|
|
51
|
+
const year = Number(migrationFolder.slice(0, 4));
|
|
52
|
+
// second param for Date() is month index, that started from 0, so we need
|
|
53
|
+
// to decrement a value for month
|
|
54
|
+
const month = Number(migrationFolder.slice(4, 6)) - 1;
|
|
55
|
+
const day = Number(migrationFolder.slice(6, 8));
|
|
56
|
+
const hour = Number(migrationFolder.slice(8, 10));
|
|
57
|
+
const min = Number(migrationFolder.slice(10, 12));
|
|
58
|
+
const sec = Number(migrationFolder.slice(12, 14));
|
|
59
|
+
const folderAsMillis = new Date(year, month, day, hour, min, sec).getTime();
|
|
52
60
|
if (!lastDbMigration || lastDbMigration.createdAt < folderAsMillis) {
|
|
53
61
|
await this.db.session().execute(query);
|
|
54
62
|
await migrationTable.insert({
|
package/package.json
CHANGED
package/serializer/serializer.js
CHANGED
|
@@ -30,6 +30,7 @@ class MigrationSerializer {
|
|
|
30
30
|
indexToReturn[name] = {
|
|
31
31
|
name,
|
|
32
32
|
columns: indexColumnToReturn,
|
|
33
|
+
isUnique: value.isUnique(),
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
36
|
if (value instanceof columns_1.Column) {
|
|
@@ -37,10 +38,22 @@ class MigrationSerializer {
|
|
|
37
38
|
name: value.getColumnName(),
|
|
38
39
|
type: value.getColumnType().getDbName(),
|
|
39
40
|
primaryKey: !!value.primaryKeyName,
|
|
40
|
-
unique: !!value.uniqueKeyName,
|
|
41
|
+
// unique: !!value.uniqueKeyName,
|
|
41
42
|
default: value.getDefaultValue() === null ? undefined : value.getDefaultValue(),
|
|
42
43
|
notNull: !value.isNullableFlag,
|
|
43
44
|
};
|
|
45
|
+
if (value.uniqueKeyName) {
|
|
46
|
+
const indexName = `${value.getParent().tableName()}_${value.getColumnName()}_index`;
|
|
47
|
+
const indexColumnToReturn = {};
|
|
48
|
+
indexColumnToReturn[value.getColumnName()] = {
|
|
49
|
+
name: value.getColumnName(),
|
|
50
|
+
};
|
|
51
|
+
indexToReturn[indexName] = {
|
|
52
|
+
name: indexName,
|
|
53
|
+
columns: indexColumnToReturn,
|
|
54
|
+
isUnique: true,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
44
57
|
const referenced = value.getReferenced();
|
|
45
58
|
if (referenced) {
|
|
46
59
|
columnToReturn[value.getColumnName()].references = {
|
|
@@ -19,6 +19,7 @@ import { AbstractColumn, Column } from '../columns/column';
|
|
|
19
19
|
import TableIndex from '../indexes/tableIndex';
|
|
20
20
|
import { ExtractModel } from './inferTypes';
|
|
21
21
|
import Enum, { ExtractEnumValues } from '../types/type';
|
|
22
|
+
import PgSmallInt from '../columns/types/pgSmallInt';
|
|
22
23
|
import PgSerial from '../columns/types/pgSerial';
|
|
23
24
|
import PgTimestamptz from '../columns/types/pgTimestamptz';
|
|
24
25
|
import PgBigSerial53, { PgBigSerial64 } from '../columns/types/pgBigSerial';
|
|
@@ -47,7 +48,7 @@ export default abstract class AbstractTable<TTable extends AbstractTable<TTable>
|
|
|
47
48
|
size?: number;
|
|
48
49
|
}): Column<PgVarChar, true, false, this>;
|
|
49
50
|
protected int(name: string): Column<PgInteger, true, false, this>;
|
|
50
|
-
protected smallInt(name: string): Column<
|
|
51
|
+
protected smallInt(name: string): Column<PgSmallInt, true, false, this>;
|
|
51
52
|
protected serial(name: string): Column<PgSerial, true, true, this>;
|
|
52
53
|
protected bigSerial(name: string, maxBytes: 'max_bytes_53'): Column<PgBigSerial53, true, true, this>;
|
|
53
54
|
protected bigSerial(name: string, maxBytes: 'max_bytes_64'): Column<PgBigSerial64, true, true, this>;
|
package/tables/abstractTable.js
CHANGED
|
@@ -74,7 +74,7 @@ class AbstractTable {
|
|
|
74
74
|
return new tableIndex_1.default(this.tableName(), columns instanceof Array ? columns : [columns]);
|
|
75
75
|
}
|
|
76
76
|
uniqueIndex(columns) {
|
|
77
|
-
return new tableIndex_1.default(this.tableName(), columns instanceof Array ? columns : [columns]);
|
|
77
|
+
return new tableIndex_1.default(this.tableName(), columns instanceof Array ? columns : [columns], true);
|
|
78
78
|
}
|
|
79
79
|
varchar(name, params = {}) {
|
|
80
80
|
return new column_1.Column(this, name, new pgVarChar_1.default(params.size));
|
package/test.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const _1 = require(".");
|
|
4
|
+
const builders_1 = require("./builders");
|
|
4
5
|
const citiesTable_1 = require("./docs/tables/citiesTable");
|
|
5
6
|
const usersTable_1 = require("./docs/tables/usersTable");
|
|
6
7
|
const consoleLogger_1 = require("./logger/consoleLogger");
|
|
@@ -21,17 +22,83 @@ const fromTypeFile = (filepath) => {
|
|
|
21
22
|
(async () => {
|
|
22
23
|
try {
|
|
23
24
|
const db = await new _1.DbConnector()
|
|
24
|
-
.connectionString('postgresql://postgres@127.0.0.1/
|
|
25
|
+
.connectionString('postgresql://postgres@127.0.0.1/drizzle-docs')
|
|
25
26
|
.connect();
|
|
26
27
|
db.useLogger(new consoleLogger_1.default());
|
|
28
|
+
const table = new usersTable_1.default(db);
|
|
29
|
+
const citiesTable = new citiesTable_1.default(db);
|
|
30
|
+
const res = await table.select().where(builders_1.eq(table.id, 1)).all();
|
|
31
|
+
console.log(res);
|
|
32
|
+
// const res1 = await citiesTable.select().leftJoin(
|
|
33
|
+
// UsersTable,
|
|
34
|
+
// (cities) => cities.userId,
|
|
35
|
+
// (users) => users.id,
|
|
36
|
+
// ).execute();
|
|
37
|
+
// // eslint-disable-next-line array-callback-return
|
|
38
|
+
// res1.map((city, user) => {
|
|
39
|
+
// console.log(city);
|
|
40
|
+
// console.log(user);
|
|
41
|
+
// });
|
|
42
|
+
// await table.insertMany([{
|
|
43
|
+
// decimalField: 12.4,
|
|
44
|
+
// createdAt: new Date(),
|
|
45
|
+
// role: 'foo',
|
|
46
|
+
// },
|
|
47
|
+
// {
|
|
48
|
+
// decimalField: 13.4,
|
|
49
|
+
// createdAt: new Date(),
|
|
50
|
+
// role: 'foo',
|
|
51
|
+
// }]).all();
|
|
52
|
+
// const d = await table.update().where(and([
|
|
53
|
+
// or([
|
|
54
|
+
// notEq(table.id, 1),
|
|
55
|
+
// eq(table.bigIntField, 1)]),
|
|
56
|
+
// or([notEq(table.id, 2),
|
|
57
|
+
// eq(table.bigIntField, 1),
|
|
58
|
+
// and([notEq(table.id, 1),
|
|
59
|
+
// eq(table.isArchived, true),
|
|
60
|
+
// ]),
|
|
61
|
+
// ])])).set({
|
|
62
|
+
// // phone: 'updated',
|
|
63
|
+
// bigIntField: 1,
|
|
64
|
+
// decimalField: 1.2,
|
|
65
|
+
// }).all();
|
|
66
|
+
// console.log(d);
|
|
67
|
+
// await table.delete().where(eq(table.id, 4)).all();
|
|
68
|
+
// const cities = new CitiesTable(db);
|
|
69
|
+
// const d = new UsersToUserGroupsTable(db);
|
|
70
|
+
// SELECT * FROM users WHERE id = $1 and name = $2
|
|
71
|
+
// const res = notEq(table.id, 1).toQuery();
|
|
72
|
+
// const res1 = and([notEq(table.id, 1), like(table.phone, 'phone')]).toQuery();
|
|
73
|
+
// const res2 = and([
|
|
74
|
+
// or([
|
|
75
|
+
// notEq(table.id, 1),
|
|
76
|
+
// like(table.phone, 'phone')]),
|
|
77
|
+
// or([notEq(table.id, 2),
|
|
78
|
+
// like(table.phone, 'phone2'),
|
|
79
|
+
// and([notEq(table.id, 1),
|
|
80
|
+
// eq(table.isArchived, true),
|
|
81
|
+
// ]),
|
|
82
|
+
// ]),
|
|
83
|
+
// ]).toQuery();
|
|
84
|
+
// const res3 = and([notEq(table.id, 2),
|
|
85
|
+
// like(table.phone, 'phone2'),
|
|
86
|
+
// or([
|
|
87
|
+
// notEq(table.id, 1),
|
|
88
|
+
// like(table.phone, 'phone')]),
|
|
89
|
+
// ]).toQuery();
|
|
90
|
+
// // console.log(res);
|
|
91
|
+
// console.log(res2);
|
|
92
|
+
// console.log(res3);
|
|
27
93
|
// const serializer = new MigrationSerializer();
|
|
28
|
-
// const res =
|
|
94
|
+
// const res = serializer.generate([table], []);
|
|
95
|
+
// console.log(JSON.stringify(res, null, 2));
|
|
29
96
|
// fs.writeFileSync('introspected.json', JSON.stringify(res, null, 2), 'utf8');
|
|
30
97
|
// const ser = new MigrationSerializer();
|
|
31
98
|
// const d = db.create(UsersTable) as unknown as AbstractTable<any>;
|
|
32
99
|
// const f = ser.generate([d], []);
|
|
33
100
|
// console.log(JSON.stringify(f, null, 2));
|
|
34
|
-
await
|
|
101
|
+
// await drizzle.migrator(db).smigrate('drizzle.config.yml');
|
|
35
102
|
// await drizzle.migrator(db).migrate({ migrationFolder: 'drizzle' });
|
|
36
103
|
// const typesFileNames = fs.readdirSync('/Users/andrewsherman/IdeaProjects/datalayer-orm/src/examples/types');
|
|
37
104
|
// typesFileNames.forEach((filename) => {
|
|
@@ -40,8 +107,8 @@ const fromTypeFile = (filepath) => {
|
|
|
40
107
|
// console.log(typeValues);
|
|
41
108
|
// // console.log(Object.values(typeValues));
|
|
42
109
|
// });
|
|
43
|
-
const usersTable = new
|
|
44
|
-
const citiesTable = new
|
|
110
|
+
// const usersTable = new UsersTable(db);
|
|
111
|
+
// const citiesTable = new CitiesTable(db);
|
|
45
112
|
// await db.session().execute(Create.table(usersTable).build());
|
|
46
113
|
// await db.session().execute(Create.table(citiesTable).build());
|
|
47
114
|
// await usersTable.select().where(greater(usersTable.createdAtWithTimezone, new Date())).execute();
|