@aws-amplify/graphql-model-transformer 1.3.7 → 1.3.8

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 (153) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/lib/definitions.d.ts.map +1 -1
  3. package/lib/definitions.js +28 -2
  4. package/lib/definitions.js.map +1 -1
  5. package/lib/graphql-model-transformer.d.ts.map +1 -1
  6. package/lib/graphql-model-transformer.js +37 -35
  7. package/lib/graphql-model-transformer.js.map +1 -1
  8. package/lib/graphql-types/common.d.ts.map +1 -1
  9. package/lib/graphql-types/common.js +16 -18
  10. package/lib/graphql-types/common.js.map +1 -1
  11. package/lib/graphql-types/mutation.js +12 -12
  12. package/lib/graphql-types/mutation.js.map +1 -1
  13. package/lib/rds-lambda.zip +0 -0
  14. package/lib/resolvers/common.d.ts.map +1 -1
  15. package/lib/resolvers/common.js.map +1 -1
  16. package/lib/resolvers/dynamodb/mutation.d.ts.map +1 -1
  17. package/lib/resolvers/dynamodb/mutation.js +10 -8
  18. package/lib/resolvers/dynamodb/mutation.js.map +1 -1
  19. package/lib/resolvers/dynamodb/query.d.ts.map +1 -1
  20. package/lib/resolvers/dynamodb/query.js +1 -4
  21. package/lib/resolvers/dynamodb/query.js.map +1 -1
  22. package/lib/resolvers/dynamodb/subscriptions.d.ts.map +1 -1
  23. package/lib/resolvers/dynamodb/subscriptions.js.map +1 -1
  24. package/lib/resolvers/generators/rds-vtl-generator.d.ts.map +1 -1
  25. package/lib/resolvers/generators/rds-vtl-generator.js.map +1 -1
  26. package/lib/resolvers/generators/vtl-generator.d.ts.map +1 -1
  27. package/lib/resolvers/index.d.ts.map +1 -1
  28. package/lib/resolvers/index.js.map +1 -1
  29. package/lib/resolvers/rds/mutation.d.ts.map +1 -1
  30. package/lib/resolvers/rds/mutation.js.map +1 -1
  31. package/lib/resolvers/rds/query.d.ts.map +1 -1
  32. package/lib/resolvers/rds/query.js.map +1 -1
  33. package/lib/resolvers/rds/resolver.d.ts.map +1 -1
  34. package/lib/resolvers/rds/resolver.js +1 -1
  35. package/lib/resolvers/rds/resolver.js.map +1 -1
  36. package/lib/resources/dynamo-model-resource-generator.d.ts.map +1 -1
  37. package/lib/resources/dynamo-model-resource-generator.js.map +1 -1
  38. package/lib/resources/model-resource-generator.d.ts.map +1 -1
  39. package/lib/resources/model-resource-generator.js +12 -4
  40. package/lib/resources/model-resource-generator.js.map +1 -1
  41. package/lib/resources/rds-model-resource-generator.d.ts.map +1 -1
  42. package/lib/resources/rds-model-resource-generator.js +1 -1
  43. package/lib/resources/rds-model-resource-generator.js.map +1 -1
  44. package/package.json +6 -6
  45. package/rds-lambda/node_modules/.package-lock.json +209 -221
  46. package/rds-lambda/node_modules/@aws-sdk/client-ssm/package.json +17 -18
  47. package/rds-lambda/node_modules/@aws-sdk/client-sso/package.json +14 -15
  48. package/rds-lambda/node_modules/@aws-sdk/client-sso-oidc/package.json +14 -15
  49. package/rds-lambda/node_modules/@aws-sdk/client-sts/package.json +17 -18
  50. package/rds-lambda/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
  51. package/rds-lambda/node_modules/@aws-sdk/credential-provider-ini/package.json +6 -6
  52. package/rds-lambda/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
  53. package/rds-lambda/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
  54. package/rds-lambda/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
  55. package/rds-lambda/node_modules/@aws-sdk/credential-provider-web-identity/package.json +2 -2
  56. package/rds-lambda/node_modules/@aws-sdk/middleware-host-header/package.json +2 -2
  57. package/rds-lambda/node_modules/@aws-sdk/middleware-logger/package.json +2 -2
  58. package/rds-lambda/node_modules/@aws-sdk/middleware-recursion-detection/package.json +2 -2
  59. package/rds-lambda/node_modules/@aws-sdk/middleware-sdk-sts/package.json +3 -3
  60. package/rds-lambda/node_modules/@aws-sdk/middleware-signing/package.json +2 -2
  61. package/rds-lambda/node_modules/@aws-sdk/middleware-user-agent/package.json +3 -3
  62. package/rds-lambda/node_modules/@aws-sdk/token-providers/package.json +3 -3
  63. package/rds-lambda/node_modules/@aws-sdk/types/package.json +2 -1
  64. package/rds-lambda/node_modules/@aws-sdk/util-endpoints/package.json +2 -2
  65. package/rds-lambda/node_modules/@aws-sdk/util-user-agent-browser/package.json +2 -2
  66. package/rds-lambda/node_modules/@aws-sdk/util-user-agent-node/package.json +2 -2
  67. package/rds-lambda/node_modules/@babel/compat-data/data/plugin-bugfixes.json +2 -0
  68. package/rds-lambda/node_modules/@babel/compat-data/data/plugins.json +8 -0
  69. package/rds-lambda/node_modules/@babel/compat-data/package.json +1 -1
  70. package/rds-lambda/node_modules/@babel/core/package.json +7 -7
  71. package/rds-lambda/node_modules/@babel/generator/package.json +2 -2
  72. package/rds-lambda/node_modules/@babel/helper-compilation-targets/package.json +5 -5
  73. package/rds-lambda/node_modules/@babel/helper-module-transforms/README.md +1 -1
  74. package/rds-lambda/node_modules/@babel/helper-module-transforms/package.json +10 -6
  75. package/rds-lambda/node_modules/@types/jest/README.md +1 -1
  76. package/rds-lambda/node_modules/@types/jest/package.json +2 -2
  77. package/rds-lambda/node_modules/@types/node/README.md +1 -1
  78. package/rds-lambda/node_modules/@types/node/package.json +2 -2
  79. package/rds-lambda/node_modules/caniuse-lite/package.json +1 -1
  80. package/rds-lambda/node_modules/commander/Readme.md +7 -2
  81. package/rds-lambda/node_modules/commander/package.json +17 -17
  82. package/rds-lambda/node_modules/electron-to-chromium/full-chromium-versions.json +1 -1
  83. package/rds-lambda/node_modules/electron-to-chromium/full-versions.json +1 -1
  84. package/rds-lambda/node_modules/electron-to-chromium/package.json +1 -1
  85. package/rds-lambda/node_modules/electron-to-chromium/versions.json +1 -1
  86. package/rds-lambda/node_modules/knex/CHANGELOG.md +63 -21
  87. package/rds-lambda/node_modules/knex/CONTRIBUTING.md +1 -1
  88. package/rds-lambda/node_modules/knex/LICENSE +22 -22
  89. package/rds-lambda/node_modules/knex/README.md +32 -31
  90. package/rds-lambda/node_modules/knex/UPGRADING.md +94 -82
  91. package/rds-lambda/node_modules/knex/knex.mjs +11 -0
  92. package/rds-lambda/node_modules/knex/lib/dialects/oracle/DEAD_CODE.md +3 -3
  93. package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/cjs.stub +15 -15
  94. package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/coffee.stub +13 -13
  95. package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/eg.stub +14 -14
  96. package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/js-schema.stub +22 -22
  97. package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/js.stub +22 -22
  98. package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/knexfile-coffee.stub +34 -34
  99. package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/knexfile-eg.stub +43 -43
  100. package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/knexfile-js.stub +47 -47
  101. package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/knexfile-ls.stub +35 -35
  102. package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/knexfile-ts.stub +47 -47
  103. package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/ls.stub +14 -14
  104. package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/mjs.stub +23 -23
  105. package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/ts-schema.stub +21 -21
  106. package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/ts.stub +21 -21
  107. package/rds-lambda/node_modules/knex/lib/migrations/seed/stub/coffee.stub +9 -9
  108. package/rds-lambda/node_modules/knex/lib/migrations/seed/stub/eg.stub +11 -11
  109. package/rds-lambda/node_modules/knex/lib/migrations/seed/stub/js.stub +13 -13
  110. package/rds-lambda/node_modules/knex/lib/migrations/seed/stub/ls.stub +11 -11
  111. package/rds-lambda/node_modules/knex/lib/migrations/seed/stub/mjs.stub +12 -12
  112. package/rds-lambda/node_modules/knex/lib/migrations/seed/stub/ts.stub +13 -13
  113. package/rds-lambda/node_modules/knex/package.json +21 -18
  114. package/rds-lambda/node_modules/knex/scripts/docker-compose.yml +2 -2
  115. package/rds-lambda/node_modules/knex/scripts/next-release-howto.md +1 -1
  116. package/rds-lambda/node_modules/knex/scripts/oracledb-install-driver-libs.sh +82 -82
  117. package/rds-lambda/node_modules/knex/scripts/release.sh +36 -34
  118. package/rds-lambda/node_modules/knex/scripts/stress-test/README.txt +18 -18
  119. package/rds-lambda/node_modules/knex/scripts/stress-test/docker-compose.yml +16 -16
  120. package/rds-lambda/node_modules/pg-connection-string/package.json +2 -2
  121. package/rds-lambda/node_modules/semver/package.json +19 -9
  122. package/rds-lambda/package-lock.json +209 -221
  123. package/src/__tests__/model-transformer.test.ts +130 -139
  124. package/src/__tests__/test-utils/helpers.ts +1 -1
  125. package/src/__tests__/test-utils/rds_utils.test.ts +29 -68
  126. package/src/definitions.ts +28 -2
  127. package/src/graphql-model-transformer.ts +72 -74
  128. package/src/graphql-types/common.ts +41 -41
  129. package/src/graphql-types/mutation.ts +12 -12
  130. package/src/resolvers/common.ts +1 -12
  131. package/src/resolvers/dynamodb/mutation.ts +16 -13
  132. package/src/resolvers/dynamodb/query.ts +6 -12
  133. package/src/resolvers/dynamodb/subscriptions.ts +1 -3
  134. package/src/resolvers/generators/rds-vtl-generator.ts +1 -4
  135. package/src/resolvers/generators/vtl-generator.ts +5 -5
  136. package/src/resolvers/index.ts +1 -3
  137. package/src/resolvers/rds/mutation.ts +17 -6
  138. package/src/resolvers/rds/query.ts +4 -12
  139. package/src/resolvers/rds/resolver.ts +8 -13
  140. package/src/resources/dynamo-model-resource-generator.ts +12 -22
  141. package/src/resources/model-resource-generator.ts +54 -24
  142. package/src/resources/rds-model-resource-generator.ts +9 -23
  143. package/tsconfig.json +4 -4
  144. package/tsconfig.tsbuildinfo +1 -1
  145. package/rds-lambda/node_modules/@nicolo-ribaudo/semver-v6/CHANGELOG.md +0 -70
  146. package/rds-lambda/node_modules/@nicolo-ribaudo/semver-v6/LICENSE +0 -15
  147. package/rds-lambda/node_modules/@nicolo-ribaudo/semver-v6/README.md +0 -454
  148. package/rds-lambda/node_modules/@nicolo-ribaudo/semver-v6/package.json +0 -28
  149. package/rds-lambda/node_modules/@nicolo-ribaudo/semver-v6/range.bnf +0 -16
  150. package/rds-lambda/node_modules/pg/node_modules/pg-connection-string/LICENSE +0 -21
  151. package/rds-lambda/node_modules/pg/node_modules/pg-connection-string/README.md +0 -77
  152. package/rds-lambda/node_modules/pg/node_modules/pg-connection-string/package.json +0 -40
  153. package/rds-lambda/node_modules/semver/CHANGELOG.md +0 -70
@@ -1,18 +1,60 @@
1
1
  # Master (Unreleased)
2
2
 
3
- # 2.4.2 - 22 January, 2022
3
+ # 2.5.1 - 12 July, 2023
4
+
5
+ ### Bug fixes
6
+
7
+ - Fix Linting #5455 - #5460
8
+
9
+ # 2.5.0 - 08 July, 2023
10
+
11
+ ### New features
12
+
13
+ - Add uuid helper function (#5617)
14
+ - Add `nativeBindings` option to `better-sqlite3` options (#5461)
15
+ - Add QueryBuilder#updateFrom (#5386)
16
+ - Add readonly transaction access mode (#5445)
17
+ - Add readonly option to Better-SQLite3 (#5530)
18
+ - Add EXCEPT as a valid keyword (#5357)
19
+ - Add ability to prepend query comments (#5289)
20
+ - Add fetchAsString option (#5484)
21
+
22
+ ### Bug fixes
23
+
24
+ - Avoid password leaks on query logs (#5559)
25
+ - Add knex.mjs to files in package.json (#5518)
26
+ - Handle numeric array elements in .orderBy() (#5551)
27
+ - Attach error handler early enough (#5552)
28
+ - Fix Returning \* in Oracle (#5598)
29
+ - Fix indexType option in `Postgres` (#5601)
30
+ - Add mjs extension type (#5616)
31
+ - Use implicit check on json fields for OracleDB (#5478)
32
+ - Fix when manually close source stream (#5466)
33
+ - Fix case sensitive issue with get table (#5509)
34
+
35
+ ### Typings
36
+
37
+ - Add Object syntax overload to increment method (#5512)
38
+ - Add object syntax overload to decrement method (#5555)
39
+ - Fix typing for toSql (#5594)
40
+ - Add ResolveTableType for `.merge()` (#5605)
41
+ - Add missing types for havingNull and havingNotNull (#5529)
42
+ - Add collate to the columnbuilder interface (#5568)
43
+ - TableBuilder methods return the SchemaBuilder. (#5486)
44
+
45
+ # 2.4.2 - 22 January, 2023
4
46
 
5
47
  ### Bug fixes
6
48
 
7
49
  - CLI: Fix incorrent EOL causing errors on Linux #5455
8
50
 
9
- # 2.4.1 - 18 January, 2022
51
+ # 2.4.1 - 18 January, 2023
10
52
 
11
53
  ### Bug fixes
12
54
 
13
55
  - PostgreSQL: Fix Malformed array literal 2.4.0 Regression #5439
14
56
 
15
- # 2.4.0 - 06 January, 2022
57
+ # 2.4.0 - 06 January, 2023
16
58
 
17
59
  ### New features:
18
60
 
@@ -465,13 +507,13 @@ Note: there are many breaking changes in this version, particularly in TypeScrip
465
507
  - Change default to not trigger a promise rejection for transactions with a specified handler #4195
466
508
  - Make toSQL().toNative() work for Raw to match the API for QueryBuilder #4058
467
509
  - Allow 'match' operator #3569
468
- - Support optimizer hints #4243
510
+ - Support optimizer hints #4243
469
511
  - Add parameter to prevent autoincrement columns from being primary keys #4266
470
- - Make "first" and "pluck" mutually exclusive #4280
512
+ - Make "first" and "pluck" mutually exclusive #4280
471
513
  - Added merge strategy to allow selecting columns to upsert. #4252
472
514
  - Throw error if the array passed to insert is empty #4289
473
515
  - Events: introduce queryContext on query-error #4301
474
- - CLI: Use UTC timestamp for new migrations #4245
516
+ - CLI: Use UTC timestamp for new migrations #4245
475
517
  - MSSQL: Replace MSSQL dialect with Tedious.js implementation #2857 #4281
476
518
  - MSSQL: Use "nvarchar(max)" for ".json()" #4278
477
519
  - MSSQL: Schema builder - add predictable constraint names for default values #4319
@@ -513,9 +555,9 @@ Note: there are many breaking changes in this version, particularly in TypeScrip
513
555
  - Various internal refactorings #4175 #4177 #4178 #4192
514
556
  - Refactor to classes #4190 #4191 #4193 #4210 #4253
515
557
  - Move transaction type tests to TSD #4208
516
- - Clean up destroy logic #4248
517
- - Colorize code snippets in readme files #4234
518
- - Add "Ecosystem" documentation for Knex plugins #4183
558
+ - Clean up destroy logic #4248
559
+ - Colorize code snippets in readme files #4234
560
+ - Add "Ecosystem" documentation for Knex plugins #4183
519
561
  - Documentation cleanup
520
562
  - SQLite: Use SQLite "rename column" instead of a DDL helper #4200
521
563
  - SQLite: Simplify reinsert logic when altering a table #4272
@@ -570,7 +612,7 @@ Note: there are many breaking changes in this version, particularly in TypeScrip
570
612
 
571
613
  ### Bug fixes:
572
614
 
573
- - Make sure query-response and query-error events contain _knexTxId #4160
615
+ - Make sure query-response and query-error events contain \_knexTxId #4160
574
616
 
575
617
  ### Test / internal changes:
576
618
 
@@ -826,7 +868,7 @@ Note: there are many breaking changes in this version, particularly in TypeScrip
826
868
 
827
869
  ### Bug fixes:
828
870
 
829
- - Correctly handle dateToString escaping without timezone passed #3742
871
+ - Correctly handle dateToString escaping without timezone passed #3742
830
872
  - Make protocol length check more defensive #3744
831
873
 
832
874
  ### Typings:
@@ -837,7 +879,7 @@ Note: there are many breaking changes in this version, particularly in TypeScrip
837
879
 
838
880
  ### Bug fixes:
839
881
 
840
- - Added missing call to _reject in Transactor#transaction #3706
882
+ - Added missing call to \_reject in Transactor#transaction #3706
841
883
  - Fix method binding on knex proxy #3717
842
884
  - Oracle: Transaction_OracleDB can use config.connection #3731
843
885
 
@@ -848,7 +890,7 @@ Note: there are many breaking changes in this version, particularly in TypeScrip
848
890
  ### Test / internal changes:
849
891
 
850
892
  - Cleanup/remove transaction stalling #3716
851
- - Rewrote Transaction#acquireConnection() methods to use async #3707
893
+ - Rewrote Transaction#acquireConnection() methods to use async #3707
852
894
 
853
895
  # 0.20.11 - 26 February, 2020
854
896
 
@@ -884,7 +926,7 @@ Note: there are many breaking changes in this version, particularly in TypeScrip
884
926
  ### Typings:
885
927
 
886
928
  - `fn.now` takes optionally a precision argument. #3662
887
- - PG: Include SSL in connection definition #3659
929
+ - PG: Include SSL in connection definition #3659
888
930
 
889
931
  ### Test / internal changes:
890
932
 
@@ -898,7 +940,7 @@ Note: there are many breaking changes in this version, particularly in TypeScrip
898
940
 
899
941
  ### Typings:
900
942
 
901
- - MSSQL: Add `enableArithAbort` to `MsSqlConnectionConfig`
943
+ - MSSQL: Add `enableArithAbort` to `MsSqlConnectionConfig`
902
944
 
903
945
  ### Test / internal changes:
904
946
 
@@ -917,7 +959,7 @@ Note: there are many breaking changes in this version, particularly in TypeScrip
917
959
 
918
960
  ### Typings:
919
961
 
920
- - Fix incorrect type of QueryBuilder.first('*') result #3621
962
+ - Fix incorrect type of QueryBuilder.first('\*') result #3621
921
963
 
922
964
  # 0.20.7 - 07 January, 2020
923
965
 
@@ -1072,7 +1114,7 @@ Note: there are many breaking changes in this version, particularly in TypeScrip
1072
1114
  ### Typings:
1073
1115
 
1074
1116
  - Add missing Migrator.list typing #3460
1075
- - Fix Typescript type inference for to better support wildcard (*) calls #3444
1117
+ - Fix Typescript type inference for to better support wildcard (\*) calls #3444
1076
1118
  - Make options argument optional in timeout #3442
1077
1119
 
1078
1120
  ### Test / internal changes:
@@ -1109,7 +1151,7 @@ Note: there are many breaking changes in this version, particularly in TypeScrip
1109
1151
 
1110
1152
  ### Changes:
1111
1153
 
1112
- - migrate: Refactor _lockMigrations to avoid forUpdate - makes migrations compatible with CockroachDB #3395
1154
+ - migrate: Refactor \_lockMigrations to avoid forUpdate - makes migrations compatible with CockroachDB #3395
1113
1155
 
1114
1156
  # 0.19.2 - 17 August, 2019
1115
1157
 
@@ -1120,7 +1162,7 @@ Note: there are many breaking changes in this version, particularly in TypeScrip
1120
1162
 
1121
1163
  ### New features:
1122
1164
 
1123
- - Fallback to JSON when using JSONB in MySQL #3394
1165
+ - Fallback to JSON when using JSONB in MySQL #3394
1124
1166
 
1125
1167
  # 0.19.1 - 23 July, 2019
1126
1168
 
@@ -1139,7 +1181,7 @@ Note: there are many breaking changes in this version, particularly in TypeScrip
1139
1181
 
1140
1182
  ### Changes:
1141
1183
 
1142
- - Pooling: tarn.js connection pool was updated to version 2.0.0. This fixes issue with destroying connections and introduces support for connection pool event handlers. Please see tarn.js documentation for more details #3345
1184
+ - Pooling: tarn.js connection pool was updated to version 2.0.0. This fixes issue with destroying connections and introduces support for connection pool event handlers. Please see tarn.js documentation for more details #3345
1143
1185
  - Pooling: Passing unsupported pooling configuration options now throws an error
1144
1186
  - Pooling: `beforeDestroy` configuration option was removed
1145
1187
 
@@ -1330,7 +1372,7 @@ Note: there are many breaking changes in this version, particularly in TypeScrip
1330
1372
  - Typings: Add 'string' as accepted Knex constructor type definition #3105
1331
1373
  - Typings: Add boolean as a column name in join #3121
1332
1374
  - Typings: Add missing clearOrder & clearCounters types #3109
1333
- - Dependencies: Fix security warning #3082
1375
+ - Dependencies: Fix security warning #3082
1334
1376
  - Do not use unsupported column width/length arguments on data types int and tinyint in MSSQL #2738
1335
1377
 
1336
1378
  ### Changes:
@@ -1,6 +1,6 @@
1
1
  ## How to contribute to Knex.js
2
2
 
3
- - Make changes in the `/lib` directory.
3
+ - Make changes in the `/lib` directory.
4
4
 
5
5
  - Before sending a pull request for a feature or bug fix, be sure to have
6
6
  [tests](https://github.com/knex/knex/tree/master/test). Every pull request that changes the queries should have
@@ -1,22 +1,22 @@
1
- Copyright (c) 2013-present Tim Griesser
2
-
3
- Permission is hereby granted, free of charge, to any person
4
- obtaining a copy of this software and associated documentation
5
- files (the "Software"), to deal in the Software without
6
- restriction, including without limitation the rights to use,
7
- copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- copies of the Software, and to permit persons to whom the
9
- Software is furnished to do so, subject to the following
10
- conditions:
11
-
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2013-present Tim Griesser
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -6,7 +6,6 @@
6
6
  [![Coverage Status](https://coveralls.io/repos/knex/knex/badge.svg?branch=master)](https://coveralls.io/r/knex/knex?branch=master)
7
7
  [![Dependencies Status](https://img.shields.io/librariesio/github/knex/knex)](https://libraries.io/npm/knex)
8
8
  [![Gitter chat](https://badges.gitter.im/tgriesser/knex.svg)](https://gitter.im/tgriesser/knex)
9
- [![Language Grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/knex/knex.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/knex/knex/context:javascript)
10
9
 
11
10
  > **A SQL query builder that is _flexible_, _portable_, and _fun_ to use!**
12
11
 
@@ -21,14 +20,13 @@ Node.js, featuring:
21
20
 
22
21
  Node.js versions 12+ are supported.
23
22
 
24
- * Take a look at the [full documentation](https://knex.github.io/documentation) to get started!
25
- * Browse the [list of plugins and tools](https://github.com/knex/knex/blob/master/ECOSYSTEM.md) built for knex
26
- * Check out our [recipes wiki](https://github.com/knex/knex/wiki/Recipes) to search for solutions to some specific problems
27
- * In case of upgrading from an older version, see [migration guide](https://github.com/knex/knex/blob/master/UPGRADING.md)
23
+ - Take a look at the [full documentation](https://knex.github.io/documentation) to get started!
24
+ - Browse the [list of plugins and tools](https://github.com/knex/knex/blob/master/ECOSYSTEM.md) built for knex
25
+ - Check out our [recipes wiki](https://github.com/knex/knex/wiki/Recipes) to search for solutions to some specific problems
26
+ - In case of upgrading from an older version, see [migration guide](https://github.com/knex/knex/blob/master/UPGRADING.md)
28
27
 
29
28
  You can report bugs and discuss features on the [GitHub issues page](https://github.com/knex/knex/issues) or send tweets to [@kibertoad](http://twitter.com/kibertoad).
30
29
 
31
-
32
30
  For support and questions, join our [Gitter channel](https://gitter.im/tgriesser/knex).
33
31
 
34
32
  For knex-based Object Relational Mapper, see:
@@ -52,46 +50,46 @@ const knex = require('knex')({
52
50
  });
53
51
 
54
52
  try {
55
-
56
53
  // Create a table
57
54
  await knex.schema
58
- .createTable('users', table => {
55
+ .createTable('users', (table) => {
59
56
  table.increments('id');
60
57
  table.string('user_name');
61
58
  })
62
59
  // ...and another
63
- .createTable('accounts', table => {
60
+ .createTable('accounts', (table) => {
64
61
  table.increments('id');
65
62
  table.string('account_name');
66
- table
67
- .integer('user_id')
68
- .unsigned()
69
- .references('users.id');
70
- })
63
+ table.integer('user_id').unsigned().references('users.id');
64
+ });
71
65
 
72
66
  // Then query the table...
73
- const insertedRows = await knex('users').insert({ user_name: 'Tim' })
67
+ const insertedRows = await knex('users').insert({ user_name: 'Tim' });
74
68
 
75
69
  // ...and using the insert id, insert into the other table.
76
- await knex('accounts').insert({ account_name: 'knex', user_id: insertedRows[0] })
70
+ await knex('accounts').insert({
71
+ account_name: 'knex',
72
+ user_id: insertedRows[0],
73
+ });
77
74
 
78
75
  // Query both of the rows.
79
76
  const selectedRows = await knex('users')
80
77
  .join('accounts', 'users.id', 'accounts.user_id')
81
- .select('users.user_name as user', 'accounts.account_name as account')
78
+ .select('users.user_name as user', 'accounts.account_name as account');
82
79
 
83
80
  // map over the results
84
- const enrichedRows = selectedRows.map(row => ({ ...row, active: true }))
81
+ const enrichedRows = selectedRows.map((row) => ({ ...row, active: true }));
85
82
 
86
83
  // Finally, add a catch statement
87
- } catch(e) {
84
+ } catch (e) {
88
85
  console.error(e);
89
- };
86
+ }
90
87
  ```
91
88
 
92
89
  ## TypeScript example
90
+
93
91
  ```ts
94
- import { Knex, knex } from 'knex'
92
+ import { Knex, knex } from 'knex';
95
93
 
96
94
  interface User {
97
95
  id: number;
@@ -121,28 +119,31 @@ try {
121
119
 
122
120
  If you are launching your Node application with `--experimental-modules`, `knex.mjs` should be picked up automatically and named ESM import should work out-of-the-box.
123
121
  Otherwise, if you want to use named imports, you'll have to import knex like this:
122
+
124
123
  ```js
125
- import { knex } from 'knex/knex.mjs'
124
+ import { knex } from 'knex/knex.mjs';
126
125
  ```
127
126
 
128
127
  You can also just do the default import:
128
+
129
129
  ```js
130
- import knex from 'knex'
130
+ import knex from 'knex';
131
131
  ```
132
132
 
133
133
  If you are not using TypeScript and would like the IntelliSense of your IDE to work correctly, it is recommended to set the type explicitly:
134
+
134
135
  ```js
135
136
  /**
136
137
  * @type {Knex}
137
138
  */
138
139
  const database = knex({
139
- client: 'mysql',
140
- connection: {
141
- host : '127.0.0.1',
142
- user : 'your_database_user',
143
- password : 'your_database_password',
144
- database : 'myapp_test'
145
- }
146
- });
140
+ client: 'mysql',
141
+ connection: {
142
+ host: '127.0.0.1',
143
+ user: 'your_database_user',
144
+ password: 'your_database_password',
145
+ database: 'myapp_test',
146
+ },
147
+ });
147
148
  database.migrate.latest();
148
149
  ```