drizzle-orm 0.10.3 → 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/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/package.json +1 -1
- package/tables/abstractTable.d.ts +2 -1
- package/test.js +45 -3
package/package.json
CHANGED
|
@@ -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/test.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
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");
|
|
4
7
|
const consoleLogger_1 = require("./logger/consoleLogger");
|
|
5
8
|
// import { Pool } from 'pg';
|
|
6
9
|
// import { DB } from '.';
|
|
@@ -19,10 +22,49 @@ const fromTypeFile = (filepath) => {
|
|
|
19
22
|
(async () => {
|
|
20
23
|
try {
|
|
21
24
|
const db = await new _1.DbConnector()
|
|
22
|
-
.connectionString('postgresql://postgres@127.0.0.1/
|
|
25
|
+
.connectionString('postgresql://postgres@127.0.0.1/drizzle-docs')
|
|
23
26
|
.connect();
|
|
24
27
|
db.useLogger(new consoleLogger_1.default());
|
|
25
|
-
|
|
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();
|
|
26
68
|
// const cities = new CitiesTable(db);
|
|
27
69
|
// const d = new UsersToUserGroupsTable(db);
|
|
28
70
|
// SELECT * FROM users WHERE id = $1 and name = $2
|
|
@@ -56,7 +98,7 @@ const fromTypeFile = (filepath) => {
|
|
|
56
98
|
// const d = db.create(UsersTable) as unknown as AbstractTable<any>;
|
|
57
99
|
// const f = ser.generate([d], []);
|
|
58
100
|
// console.log(JSON.stringify(f, null, 2));
|
|
59
|
-
await
|
|
101
|
+
// await drizzle.migrator(db).smigrate('drizzle.config.yml');
|
|
60
102
|
// await drizzle.migrator(db).migrate({ migrationFolder: 'drizzle' });
|
|
61
103
|
// const typesFileNames = fs.readdirSync('/Users/andrewsherman/IdeaProjects/datalayer-orm/src/examples/types');
|
|
62
104
|
// typesFileNames.forEach((filename) => {
|