drizzle-orm 0.10.29 → 0.10.30

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.
Files changed (124) hide show
  1. package/package.json +4 -1
  2. package/.eslintrc +0 -28
  3. package/.tslintignore +0 -1
  4. package/CHANGELOG.md +0 -202
  5. package/pnpm-lock.yaml +0 -1842
  6. package/src/builders/aggregators/abstractAggregator.ts +0 -41
  7. package/src/builders/aggregators/deleteAggregator.ts +0 -44
  8. package/src/builders/aggregators/insertAggregator.ts +0 -120
  9. package/src/builders/aggregators/selectAggregator.ts +0 -163
  10. package/src/builders/aggregators/updateAggregator.ts +0 -56
  11. package/src/builders/highLvlBuilders/abstractRequestBuilder.ts +0 -51
  12. package/src/builders/highLvlBuilders/deleteRequestBuilder.ts +0 -59
  13. package/src/builders/highLvlBuilders/insertRequestBuilder.ts +0 -75
  14. package/src/builders/highLvlBuilders/order.ts +0 -4
  15. package/src/builders/highLvlBuilders/selectRequestBuilder.ts +0 -229
  16. package/src/builders/highLvlBuilders/updateRequestBuilder.ts +0 -80
  17. package/src/builders/index.ts +0 -21
  18. package/src/builders/joinBuilders/builders/abstractJoinBuilder.ts +0 -98
  19. package/src/builders/joinBuilders/builders/selectWithFiveJoins.ts +0 -110
  20. package/src/builders/joinBuilders/builders/selectWithFourJoins.ts +0 -254
  21. package/src/builders/joinBuilders/builders/selectWithJoin.ts +0 -189
  22. package/src/builders/joinBuilders/builders/selectWithThreeJoins.ts +0 -231
  23. package/src/builders/joinBuilders/builders/selectWithTwoJoins.ts +0 -210
  24. package/src/builders/joinBuilders/join.ts +0 -40
  25. package/src/builders/joinBuilders/joinWith.ts +0 -21
  26. package/src/builders/joinBuilders/responses/selectResponseFiveJoins.ts +0 -82
  27. package/src/builders/joinBuilders/responses/selectResponseFourJoins.ts +0 -73
  28. package/src/builders/joinBuilders/responses/selectResponseThreeJoins.ts +0 -64
  29. package/src/builders/joinBuilders/responses/selectResponseTwoJoins.ts +0 -57
  30. package/src/builders/joinBuilders/responses/selectResponseWithJoin.ts +0 -49
  31. package/src/builders/joinBuilders/static.ts +0 -9
  32. package/src/builders/lowLvlBuilders/alter.ts +0 -0
  33. package/src/builders/lowLvlBuilders/create.ts +0 -115
  34. package/src/builders/lowLvlBuilders/delets/delete.ts +0 -13
  35. package/src/builders/lowLvlBuilders/delets/deleteFilter.ts +0 -17
  36. package/src/builders/lowLvlBuilders/delets/deleteFrom.ts +0 -15
  37. package/src/builders/lowLvlBuilders/inserts/insert.ts +0 -11
  38. package/src/builders/lowLvlBuilders/inserts/insertInto.ts +0 -16
  39. package/src/builders/lowLvlBuilders/inserts/onConflictInsert.ts +0 -19
  40. package/src/builders/lowLvlBuilders/inserts/valuesInsert.ts +0 -27
  41. package/src/builders/lowLvlBuilders/selects/select.ts +0 -14
  42. package/src/builders/lowLvlBuilders/selects/selectFrom.ts +0 -50
  43. package/src/builders/lowLvlBuilders/selects/selectJoined.ts +0 -44
  44. package/src/builders/lowLvlBuilders/selects/whereSelect.ts +0 -36
  45. package/src/builders/lowLvlBuilders/updates/update.ts +0 -13
  46. package/src/builders/lowLvlBuilders/updates/updateIn.ts +0 -17
  47. package/src/builders/lowLvlBuilders/updates/whereSelect.ts +0 -17
  48. package/src/builders/lowLvlBuilders/updates/whereSet.ts +0 -21
  49. package/src/builders/requestBuilders/updates/combine.ts +0 -34
  50. package/src/builders/requestBuilders/updates/increment.ts +0 -24
  51. package/src/builders/requestBuilders/updates/setObjects.ts +0 -27
  52. package/src/builders/requestBuilders/updates/static.ts +0 -15
  53. package/src/builders/requestBuilders/updates/updates.ts +0 -8
  54. package/src/builders/requestBuilders/where/and.ts +0 -35
  55. package/src/builders/requestBuilders/where/const.ts +0 -23
  56. package/src/builders/requestBuilders/where/constArray.ts +0 -37
  57. package/src/builders/requestBuilders/where/eqWhere.ts +0 -20
  58. package/src/builders/requestBuilders/where/greater.ts +0 -20
  59. package/src/builders/requestBuilders/where/greaterEq.ts +0 -20
  60. package/src/builders/requestBuilders/where/in.ts +0 -20
  61. package/src/builders/requestBuilders/where/isNotNull.ts +0 -17
  62. package/src/builders/requestBuilders/where/isNull.ts +0 -17
  63. package/src/builders/requestBuilders/where/less.ts +0 -20
  64. package/src/builders/requestBuilders/where/lessEq.ts +0 -20
  65. package/src/builders/requestBuilders/where/like.ts +0 -20
  66. package/src/builders/requestBuilders/where/notEqWhere.ts +0 -20
  67. package/src/builders/requestBuilders/where/or.ts +0 -35
  68. package/src/builders/requestBuilders/where/rawWhere.ts +0 -10
  69. package/src/builders/requestBuilders/where/static.ts +0 -60
  70. package/src/builders/requestBuilders/where/var.ts +0 -19
  71. package/src/builders/requestBuilders/where/where.ts +0 -5
  72. package/src/builders/transaction/transaction.ts +0 -21
  73. package/src/columns/column.ts +0 -195
  74. package/src/columns/index.ts +0 -10
  75. package/src/columns/types/columnType.ts +0 -8
  76. package/src/columns/types/pgBigDecimal.ts +0 -29
  77. package/src/columns/types/pgBigInt.ts +0 -36
  78. package/src/columns/types/pgBigSerial.ts +0 -36
  79. package/src/columns/types/pgBoolean.ts +0 -18
  80. package/src/columns/types/pgEnum.ts +0 -17
  81. package/src/columns/types/pgInteger.ts +0 -21
  82. package/src/columns/types/pgJsonb.ts +0 -21
  83. package/src/columns/types/pgSerial.ts +0 -18
  84. package/src/columns/types/pgSmallInt.ts +0 -18
  85. package/src/columns/types/pgText.ts +0 -18
  86. package/src/columns/types/pgTime.ts +0 -18
  87. package/src/columns/types/pgTimestamp.ts +0 -18
  88. package/src/columns/types/pgTimestamptz.ts +0 -18
  89. package/src/columns/types/pgVarChar.ts +0 -24
  90. package/src/db/db.ts +0 -43
  91. package/src/db/dbConnector.ts +0 -30
  92. package/src/db/dbStringConnector.ts +0 -29
  93. package/src/db/group_by.ts +0 -75
  94. package/src/db/index.ts +0 -4
  95. package/src/db/session.ts +0 -16
  96. package/src/docs/cases/simple_delete.ts +0 -35
  97. package/src/docs/cases/simple_insert.ts +0 -65
  98. package/src/docs/cases/simple_join.ts +0 -140
  99. package/src/docs/cases/simple_select.ts +0 -72
  100. package/src/docs/cases/simple_update.ts +0 -40
  101. package/src/docs/tables/citiesTable.ts +0 -22
  102. package/src/docs/tables/userGroupsTable.ts +0 -12
  103. package/src/docs/tables/usersTable.ts +0 -33
  104. package/src/docs/tables/usersToUserGroups.ts +0 -14
  105. package/src/docs/types/rolesType.ts +0 -4
  106. package/src/errors/baseError.ts +0 -47
  107. package/src/errors/builderError.ts +0 -31
  108. package/src/errors/dbErrors.ts +0 -24
  109. package/src/index.ts +0 -20
  110. package/src/indexes/tableIndex.ts +0 -25
  111. package/src/logger/abstractLogger.ts +0 -4
  112. package/src/logger/consoleLogger.ts +0 -11
  113. package/src/mappers/index.ts +0 -0
  114. package/src/mappers/responseMapper.ts +0 -46
  115. package/src/migrator/index.ts +0 -0
  116. package/src/migrator/migrator.ts +0 -97
  117. package/src/serializer/serializer.ts +0 -336
  118. package/src/tables/abstractTable.ts +0 -188
  119. package/src/tables/index.ts +0 -4
  120. package/src/tables/inferTypes.ts +0 -67
  121. package/src/tables/migrationsTable.ts +0 -11
  122. package/src/types/type.ts +0 -15
  123. package/src/utils/ecranate.ts +0 -4
  124. package/tsconfig.json +0 -14
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "drizzle-orm",
3
- "version": "0.10.29",
3
+ "version": "0.10.30",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
7
10
  "repository": {
8
11
  "type": "git",
9
12
  "url": "git+https://github.com/lambda-direct/drizzle-orm.git",
package/.eslintrc DELETED
@@ -1,28 +0,0 @@
1
- {
2
- "extends": ["airbnb-typescript/base"],
3
- "plugins": ["prefer-arrow"],
4
- "parserOptions": {
5
- "project": "./orm/tsconfig.json"
6
- },
7
- "rules": {
8
- "@typescript-eslint/explicit-member-accessibility": "error",
9
- "@typescript-eslint/lines-between-class-members": ["error", "always", { "exceptAfterSingleLine": true }],
10
- "no-underscore-dangle": ["off"],
11
- "@typescript-eslint/member-ordering": ["error", { "default": [
12
- "public-field",
13
- "protected-field",
14
- "private-field",
15
- "constructor",
16
- "static-method",
17
- "public-method",
18
- "protected-method",
19
- "private-method"
20
- ] }],
21
- "class-methods-use-this": "off",
22
- "import/no-named-as-default": 0,
23
- "import/no-named-as-default-member": 0,
24
- // "prefer-arrow/prefer-arrow-functions": ["error", { "classPropertiesAllowed": true }],
25
- "import/no-extraneous-dependencies": ["error", { "devDependencies": ["webpack.config.ts"] }],
26
- "linebreak-style": 0
27
- }
28
- }
package/.tslintignore DELETED
@@ -1 +0,0 @@
1
- *.test.ts
package/CHANGELOG.md DELETED
@@ -1,202 +0,0 @@
1
- # Changelog
2
-
3
- ### 0.10.6 (Fabruary 06, 2022)
4
- ### Fixes and Functionality:
5
- - Move from simple query execution to parameterized queries
6
- ### Breaking changes:
7
- - For `raw` query execution you need to provide values together with query
8
- #### Previous you could run simple query
9
- ```typescript
10
- const res: QueryResult<any> = await db.session().execute('SELECT * FROM users WHERE user.id = 1');
11
- ```
12
- #### Currently you need to provide prepared statement with values as array
13
- ```typescript
14
- const res: QueryResult<any> = await db.session().execute('SELECT * FROM users WHERE user.id = $1', [1]);
15
- ```
16
- It's still possible to execute query as before, without providing any values array. But we highly recommend to separate those
17
-
18
- ---
19
- ### 0.10.4 (Fabruary 02, 2022)
20
- ### Fixes and Functionality:
21
- - Fix `int` and `smallint` mappings from pg driver
22
- ---
23
- ### 0.10.0 (January 27, 2022)
24
- ### Breaking changes:
25
- - Move limit offset to function calls
26
- #### Previous limit/offset usage:
27
- ```typescript
28
- await usersTable.select({limit: 20, offset: 20}).all();
29
- ```
30
- #### Current limit/offset usage:
31
- ```typescript
32
- await usersTable.select().limit(20).offset(20).all();
33
- ```
34
- - Change join calls starting from second one
35
-
36
- Starting from second join you need to provide table to join from. As long as PostgreSQL has a possibility to join on tables, that already were in previous joins, we need to have a possibility to clarify from which exact table we need to join
37
- #### Previous join funcition call with parameters:
38
- ```typescript
39
- await usersToUserGroupsTable.select()
40
- .where(eq(userGroupsTable.id, 1))
41
- .leftJoin(UsersTable,
42
- (userToGroup) => userToGroup.userId,
43
- (users) => users.id)
44
- .leftJoin(UserGroupsTable,
45
- (userToGroup) => userToGroup.groupId,
46
- (userGroup) => userGroup.id)
47
- .execute()
48
- ```
49
- #### Current join funcition call with parameters:
50
- ```typescript
51
- await usersToUserGroupsTable.select()
52
- .where(eq(userGroupsTable.id, 1))
53
- .leftJoin(UsersTable,
54
- (userToGroup) => userToGroup.userId,
55
- (users) => users.id)
56
- .leftJoin(UsersToUserGroupsTable, UserGroupsTable,
57
- (userToGroup) => userToGroup.groupId,
58
- (userGroup) => userGroup.id)
59
- .execute()
60
- ```
61
- - Create partial select on simple select + on each join
62
-
63
- If you want to select only specific fields from select request you could provide your own interface with columns to map to:
64
- #### Example
65
- ```typescript
66
- const partialSelect = await usersTable.select({
67
- id: usersTable.id,
68
- phone: usersTable.phone,
69
- }).all();
70
-
71
- // Usage
72
- const { mappedId, mappedPhone } = partialSelect;
73
- ```
74
-
75
- Same could be done with specific columns selecting on joined tables
76
- #### Example
77
- ```typescript
78
- const usersWithUserGroups = await usersToUserGroupsTable.select()
79
- .where(eq(userGroupsTable.id, 1))
80
- .leftJoin(UsersTable,
81
- (userToGroup) => userToGroup.userId,
82
- (users) => users.id,
83
- // Partial fields to be selected from UsersTable
84
- {
85
- id: usersTable.id,
86
- })
87
- .leftJoin(UsersToUserGroupsTable, UserGroupsTable,
88
- (userToGroup) => userToGroup.groupId,
89
- (userGroup) => userGroup.id,
90
- // Partial fields to be selected from UserGroupsTable
91
- {
92
- id: userGroupsTable.id,
93
- })
94
- .execute();
95
- ```
96
-
97
- - Create possibility to have self FK and self joins
98
-
99
- You could create FK on same table you are creating it from
100
- #### Example
101
- ```typescript
102
- public cityId = this.int('city_id').foreignKey(CitiesTable, (table) => table.id, { onUpdate: 'CASCADE' });
103
- ```
104
- - Delete first() on execution and add findOne(), that will throw an error
105
-
106
- Previously we had `.first()` function, that was just getting first element from rows returned from `pg` driver
107
- Right now, invoking `.findOne()` function should check if response contains exactly 1 element in repsponse. If not, it will throw an error
108
- ### Example
109
- ```typescript
110
- const firstSelect = await usersTable.select().findOne();
111
- ```
112
- - Fix wrong types. Right now you won't get undefined from select query
113
- ---
114
-
115
- ### 0.9.19 (January 24, 2022)
116
- ### Fixes and Functionality:
117
- - Fix all queries by `Date`
118
-
119
- ---
120
-
121
- ### 0.9.18 (December 28, 2021)
122
- ### Fixes and Functionality:
123
- - Fix `any` type returning from `.notNull()` and `.primaryKey()` functions
124
-
125
- ---
126
-
127
- ### 0.9.17 (December 27, 2021)
128
- ### Fixes and Functionality:
129
- - Add serializer `fromDb()` method to introspect selected database to drizzle-kit json shanpsot format
130
-
131
- ---
132
- ### 0.9.16 (December 27, 2021)
133
- ### Breaking changes:
134
- - Delete `autoincrement` type on columns. Right now you should use `serial` type
135
-
136
- #### Previous serial column defining:
137
- ```typescript
138
- public id = this.int('id').autoincrement();
139
- ```
140
- #### Current serial column defining:
141
- ```typescript
142
- public id = this.serial('id');
143
- ```
144
-
145
- - Move `notNull` from column type metadata to builder chain
146
- #### Previous notNull defining:
147
- ```typescript
148
- public phone = this.varchar('phone', { notNull: true });
149
- ```
150
- #### Current notNull defining:
151
- ```typescript
152
- public phone = this.varchar('phone').notNull();
153
- ```
154
-
155
- - Divide `BigInt` into 2 types -> `BigInt53` and `BigInt64`
156
- - Divide `BigSerial` into 2 types -> `BigSerial53` and `BigSerial64`
157
-
158
- Due to have max value for big integers in postgres as 2^64 and javascript max value for integers is 2^53
159
-
160
- If you sure, that value in this column won't be more than 2^53 you could use:
161
- ```typescript
162
- public bigIntField = this.bigint('test1', 'max_bytes_53');
163
- ```
164
- that will be of type `number` in typescript
165
-
166
- If value in this column could be more than 2^53 you could use:
167
- ```typescript
168
- public bigIntField = this.bigint('test1', 'max_bytes_64');
169
- ```
170
- that will be of type `bigint` in typescript
171
- ---
172
-
173
- ### Fixes and Functionality:
174
- - Add `SET NULL` and `SET DEFAULT` for `ON DELETE` and `ON UPDATE` constraints
175
-
176
- #### Example of usage
177
- ```typescript
178
- public userId = this.int('user_id').foreignKey(UsersTable, (table) => table.id, { onUpdate: 'SET NULL' });
179
-
180
- public userId = this.int('user_id').foreignKey(UsersTable, (table) => table.id, { onDelete: 'SET DEFAULT' });
181
- ```
182
- - Add default value for timestamp
183
- ```typescript
184
- public createdAt = this.timestamp('created_at').defaultValue(Defaults.CURRENT_TIMESTAMP);
185
- ```
186
- - Add `timestamp with timezone` type
187
- ```typescript
188
- public createdAt = this.timestamptz('created_at');
189
- ```
190
- - Add migrator function to use `drizzle-kit` generated migrations
191
- ##### Provide drizzle-kit config path
192
- ```typescript
193
- await drizzle.migrator(db).migrate('src/drizzle.config.yaml');
194
- ```
195
- ##### Provide object with path to folder with migrations
196
- ```typescript
197
- await drizzle.migrator(db).migrate({ migrationFolder: 'drizzle' });
198
- ```
199
- ---
200
-
201
- ### Documentation:
202
- - Change README documentation for all changes in current release