express-sweet 1.0.12 → 1.0.13

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/docs/index.html CHANGED
@@ -6,7 +6,7 @@
6
6
  <title>Reference | Express Sweet</title>
7
7
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
8
8
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.3/css/all.css" integrity="sha384-SZXxX4whJ79/gErwcOYf+zWLeJdY/qpuqC4cAa9rOGUstPomtqpuNWT9wdPEn2fk" crossorigin="anonymous">
9
- <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/styles/agate.min.css">
9
+ <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/styles/github.min.css">
10
10
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css">
11
11
  <link href="styles/docs.css" rel="stylesheet">
12
12
  </head>
@@ -294,23 +294,13 @@ CREATE TABLE `book` (
294
294
  INSERT INTO `user` (`id`, `email`, `password`, `name`) VALUES
295
295
  (1, &#039;robin@example.com&#039;, &#039;password&#039;, &#039;Robin&#039;),
296
296
  (2, &#039;taylor@example.com&#039;, &#039;password&#039;, &#039;Taylor&#039;),
297
- (3, &#039;vivian@example.com&#039;, &#039;password&#039;, &#039;Vivian&#039;),
298
- (4, &#039;harry@example.com&#039;, &#039;password&#039;, &#039;Harry&#039;),
299
- (5, &#039;eliza@example.com&#039;, &#039;password&#039;, &#039;Eliza&#039;),
300
- (6, &#039;nancy@example.com&#039;, &#039;password&#039;, &#039;Nancy&#039;),
301
- (7, &#039;melinda@example.com&#039;, &#039;password&#039;, &#039;Melinda&#039;),
302
- (8, &#039;harley@example.com&#039;, &#039;password&#039;, &#039;Harley&#039;);
297
+ (3, &#039;vivian@example.com&#039;, &#039;password&#039;, &#039;Vivian&#039;);
303
298
 
304
299
  -- Add sample profile record
305
300
  INSERT INTO `profile` (`userId`, `address`, `tel`) VALUES
306
301
  (1, &#039;777 Brockton Avenue, Abington MA 2351&#039;, &#039;202-555-0105&#039;),
307
302
  (2, &#039;30 Memorial Drive, Avon MA 2322&#039;, &#039;&#039;),
308
- (3, &#039;250 Hartford Avenue, Bellingham MA 2019&#039;, &#039;202-555-0175&#039;),
309
- (4, &#039;700 Oak Street, Brockton MA 2301&#039;, &#039;202-555-0167&#039;),
310
- (5, &#039;66-4 Parkhurst Rd, Chelmsford MA 1824&#039;, &#039;202-555-0154&#039;),
311
- (6, &#039;591 Memorial Dr, Chicopee MA 1020&#039;, &#039;202-555-0141&#039;),
312
- (7, &#039;55 Brooksby Village Way, Danvers MA 1923&#039;, &#039;202-555-0196&#039;),
313
- (8, &#039;137 Teaticket Hwy, East Falmouth MA 2536&#039;, &#039;202-555-0167&#039;);
303
+ (3, &#039;250 Hartford Avenue, Bellingham MA 2019&#039;, &#039;202-555-0175&#039;);
314
304
 
315
305
  -- Add a sample user comment record
316
306
  INSERT INTO `comment` (`userId`, `text`) VALUES
@@ -320,12 +310,9 @@ INSERT INTO `comment` (`userId`, `text`) VALUES
320
310
 
321
311
  -- Add sample book record
322
312
  INSERT INTO `book` (`userId`, `title`) VALUES
323
- (1, &#039;The Stars Tonight&#039;),
324
- (1, &#039;A Guide to Courteous Thievery&#039;),
325
- (1, &#039;The Sound of Light&#039;),
326
- (2, &#039;The Stars Tonight&#039;),
327
- (2, &#039;Why She Said Yes&#039;);</code></pre>
328
-
313
+ (1, &#039;When Im Gone&#039;),
314
+ (1, &#039;Lose Yourself&#039;),
315
+ (2, &#039;When Im Gone&#039;);</code></pre>
329
316
  <p>
330
317
  Next, you need to set how the database is connected.<br>
331
318
  The database connection method can be set in <code>"config/database.js"</code>, so change it according to your environment.<br>
@@ -349,21 +336,21 @@ export default {
349
336
  development: {
350
337
  username: &#039;root&#039;,
351
338
  password: null,
352
- database: &#039;example&#039;,
339
+ database: &#039;testdb&#039;,
353
340
  host: &#039;localhost&#039;,
354
341
  dialect: &#039;mariadb&#039;
355
342
  },
356
343
  test: {
357
344
  username: &#039;root&#039;,
358
345
  password: null,
359
- database: &#039;example&#039;,
346
+ database: &#039;testdb&#039;,
360
347
  host: &#039;localhost&#039;,
361
348
  dialect: &#039;mariadb&#039;
362
349
  },
363
350
  production: {
364
351
  username: &#039;root&#039;,
365
352
  password: null,
366
- database: &#039;example&#039;,
353
+ database: &#039;testdb&#039;,
367
354
  host: &#039;localhost&#039;,
368
355
  dialect: &#039;mariadb&#039;
369
356
  }
@@ -377,21 +364,21 @@ module.exports = {
377
364
  development: {
378
365
  username: &#039;root&#039;,
379
366
  password: null,
380
- database: &#039;example&#039;,
367
+ database: &#039;testdb&#039;,
381
368
  host: &#039;localhost&#039;,
382
369
  dialect: &#039;mariadb&#039;
383
370
  },
384
371
  test: {
385
372
  username: &#039;root&#039;,
386
373
  password: null,
387
- database: &#039;example&#039;,
374
+ database: &#039;testdb&#039;,
388
375
  host: &#039;localhost&#039;,
389
376
  dialect: &#039;mariadb&#039;
390
377
  },
391
378
  production: {
392
379
  username: &#039;root&#039;,
393
380
  password: null,
394
- database: &#039;example&#039;,
381
+ database: &#039;testdb&#039;,
395
382
  host: &#039;localhost&#039;,
396
383
  dialect: &#039;mariadb&#039;
397
384
  }
@@ -912,13 +899,7 @@ module.exports = {
912
899
  The following example uses the user model to find the user who owns the credentials based on the username and password.<br>
913
900
  <pre><code class="js">authenticate_user: async (username, password) =&gt; {
914
901
  const UserModel = require(&#039;../models/UserModel&#039;);
915
- return UserModel.findOne({
916
- where: {
917
- email: username,
918
- password: password
919
- },
920
- raw: true
921
- });
902
+ return UserModel.findOne({where: {email: username, password: password}, raw: true});
922
903
  }</code></pre>
923
904
  </td>
924
905
  </tr>
@@ -931,10 +912,7 @@ module.exports = {
931
912
  The following example uses the user model to return the user information that owns the credentials based on the authenticated user's id.
932
913
  <pre><code class="js">subscribe_user: async (id) =&gt; {
933
914
  const UserModel = require(&#039;../models/UserModel&#039;);
934
- return UserModel.findOne({
935
- where: {id},
936
- raw: true
937
- });
915
+ return UserModel.findOne({where: {id}, raw: true});
938
916
  }</code></pre>
939
917
  </td>
940
918
  </tr>
@@ -944,9 +922,7 @@ module.exports = {
944
922
  By default, it requires an authenticated user for all requests.<br>
945
923
  You can use the <code>"allow_unauthenticated"</code> option to disable this behavior on certain requests.<br>
946
924
  For example, if you don’t want to authenticate all requests that contain "api" in the URL, set <code>"allow_unauthenticated"</code> as follows.
947
- <pre><code class="js">allow_unauthenticated: [
948
- &#039;/api&#039;
949
- ]</code></pre>
925
+ <pre><code class="js">allow_unauthenticated: [&#039;/api&#039;]</code></pre>
950
926
  </td>
951
927
  </tr>
952
928
  <tr>
@@ -1016,13 +992,7 @@ export default {
1016
992
  * @type {(username: string, password: string) =&gt; Promise&lt;{[key: string]: any}|null&gt;}
1017
993
  */
1018
994
  authenticate_user: async (username, password) =&gt; {
1019
- return UserModel.findOne({
1020
- where: {
1021
- email: username,
1022
- password: password
1023
- },
1024
- raw: true
1025
- });
995
+ return UserModel.findOne({where: {email: username, password: password}, raw: true});
1026
996
  },
1027
997
 
1028
998
  /**
@@ -1033,10 +1003,7 @@ export default {
1033
1003
  * @type {(id: number|string) =&gt; Promise&lt;{[key: string]: any}&gt;}
1034
1004
  */
1035
1005
  subscribe_user: async (id) =&gt; {
1036
- return UserModel.findOne({
1037
- where: {id},
1038
- raw: true
1039
- });
1006
+ return UserModel.findOne({where: {id}, raw: true});
1040
1007
  },
1041
1008
 
1042
1009
  /**
@@ -1099,13 +1066,7 @@ module.exports = {
1099
1066
  * @type {(username: string, password: string) =&gt; Promise&lt;{[key: string]: any}|null&gt;}
1100
1067
  */
1101
1068
  authenticate_user: async (username, password) =&gt; {
1102
- return UserModel.findOne({
1103
- where: {
1104
- email: username,
1105
- password: password
1106
- },
1107
- raw: true
1108
- });
1069
+ return UserModel.findOne({where: {email: username, password: password}, raw: true});
1109
1070
  },
1110
1071
 
1111
1072
  /**
@@ -1116,10 +1077,7 @@ module.exports = {
1116
1077
  * @type {(id: number|string) =&gt; Promise&lt;{[key: string]: any}&gt;}
1117
1078
  */
1118
1079
  subscribe_user: async (id) =&gt; {
1119
- return UserModel.findOne({
1120
- where: {id},
1121
- raw: true
1122
- });
1080
+ return UserModel.findOne({where: {id}, raw: true});
1123
1081
  },
1124
1082
 
1125
1083
  /**
@@ -1216,38 +1174,32 @@ export default {
1216
1174
  development: {
1217
1175
  username: &#039;root&#039;,
1218
1176
  password: null,
1219
- database: &#039;example&#039;,
1177
+ database: &#039;testdb&#039;,
1220
1178
  host: &#039;localhost&#039;,
1221
- port: undefined,
1179
+ port: 3306,
1222
1180
  dialect: &#039;mariadb&#039;,
1223
1181
  timezone: &#039;+09:00&#039;,
1224
1182
  logging: false
1225
- //,timezone: &#039;Etc/GMT-9&#039;
1226
- //,dialectOptions: {useUTC: false, timezone: &#039;Etc/GMT-9&#039;}
1227
1183
  },
1228
1184
  test: {
1229
1185
  username: &#039;root&#039;,
1230
1186
  password: null,
1231
- database: &#039;example&#039;,
1187
+ database: &#039;testdb&#039;,
1232
1188
  host: &#039;localhost&#039;,
1233
- port: undefined,
1189
+ port: 3306,
1234
1190
  dialect: &#039;mariadb&#039;,
1235
1191
  timezone: &#039;+09:00&#039;,
1236
1192
  logging: false
1237
- //,timezone: &#039;Etc/GMT-9&#039;
1238
- //,dialectOptions: {useUTC: false, timezone: &#039;Etc/GMT-9&#039;}
1239
1193
  },
1240
1194
  production: {
1241
1195
  username: &#039;root&#039;,
1242
1196
  password: null,
1243
- database: &#039;example&#039;,
1197
+ database: &#039;testdb&#039;,
1244
1198
  host: &#039;localhost&#039;,
1245
- port: undefined,
1199
+ port: 3306,
1246
1200
  dialect: &#039;mariadb&#039;,
1247
1201
  timezone: &#039;+09:00&#039;,
1248
1202
  logging: false
1249
- //,timezone: &#039;Etc/GMT-9&#039;
1250
- //,dialectOptions: {useUTC: false, timezone: &#039;Etc/GMT-9&#039;}
1251
1203
  }
1252
1204
  }</code></pre>
1253
1205
  </div>
@@ -1259,38 +1211,32 @@ module.exports = {
1259
1211
  development: {
1260
1212
  username: &#039;root&#039;,
1261
1213
  password: null,
1262
- database: &#039;example&#039;,
1214
+ database: &#039;testdb&#039;,
1263
1215
  host: &#039;localhost&#039;,
1264
- port: undefined,
1216
+ port: 3306,
1265
1217
  dialect: &#039;mariadb&#039;,
1266
1218
  timezone: &#039;+09:00&#039;,
1267
1219
  logging: false
1268
- //,timezone: &#039;Etc/GMT-9&#039;
1269
- //,dialectOptions: {useUTC: false, timezone: &#039;Etc/GMT-9&#039;}
1270
1220
  },
1271
1221
  test: {
1272
1222
  username: &#039;root&#039;,
1273
1223
  password: null,
1274
- database: &#039;example&#039;,
1224
+ database: &#039;testdb&#039;,
1275
1225
  host: &#039;localhost&#039;,
1276
- port: undefined,
1226
+ port: 3306,
1277
1227
  dialect: &#039;mariadb&#039;,
1278
1228
  timezone: &#039;+09:00&#039;,
1279
1229
  logging: false
1280
- //,timezone: &#039;Etc/GMT-9&#039;
1281
- //,dialectOptions: {useUTC: false, timezone: &#039;Etc/GMT-9&#039;}
1282
1230
  },
1283
1231
  production: {
1284
1232
  username: &#039;root&#039;,
1285
1233
  password: null,
1286
- database: &#039;example&#039;,
1234
+ database: &#039;testdb&#039;,
1287
1235
  host: &#039;localhost&#039;,
1288
- port: undefined,
1236
+ port: 3306,
1289
1237
  dialect: &#039;mariadb&#039;,
1290
1238
  timezone: &#039;+09:00&#039;,
1291
1239
  logging: false
1292
- //,timezone: &#039;Etc/GMT-9&#039;
1293
- //,dialectOptions: {useUTC: false, timezone: &#039;Etc/GMT-9&#039;}
1294
1240
  }
1295
1241
  }</code></pre>
1296
1242
  </div>
@@ -2196,9 +2142,8 @@ let value = &#039;2&#039;
2196
2142
  <!--begin::Accessing Models-->
2197
2143
  <h2 id="model-accessing">Accessing Models</h2>
2198
2144
  <p>
2199
- Model classes are stored in the "models" directory in the root directory.<br>
2200
- Loading the model gives you instant access to the model’s functions for working with the database.<br>
2201
- In the following example, "routes/users.js" loads "models/UserModel.js" and tries CRUD to the user table.
2145
+ Place the model in the "models" directory of the root directory.<br>
2146
+ When you load the model, you have immediate access to the model's functions for working with the database.
2202
2147
  </p>
2203
2148
  <div class="example">
2204
2149
  <ul class="nav nav-tabs">
@@ -2211,34 +2156,34 @@ let value = &#039;2&#039;
2211
2156
  </ul>
2212
2157
  <div class="tab-content">
2213
2158
  <div class="tab-pane fade show active" id="model-accessing-esm">
2214
- <pre><code class="js">import UserModel from &#039;../models/UserModel&#039;;
2159
+ <pre><code class="js">import BookModel from &#039;../models/BookModel&#039;;
2215
2160
 
2216
- // INSERT INTO user (email, name) VALUES (&#039;robin@example.com&#039;, &#039;Robin&#039;)
2217
- await UserModel.create({email: &#039;robin@example.com&#039;, name: &#039;Robin&#039;});
2161
+ // INSERT INTO book (title) VALUES (&#039;When Im Gone&#039;)
2162
+ await BookModel.create({title: &#039;When Im Gone&#039;});
2218
2163
 
2219
- // SELECT * FROM user
2220
- await UserModel.findAll();
2164
+ // SELECT * FROM book
2165
+ await BookModel.findAll();
2221
2166
 
2222
- // UPDATE user SET name = &#039;Taylor&#039; WHERE id= 1
2223
- await UserModel.update({name: &#039;Taylor&#039;}, {where: {id: 1}});
2167
+ // UPDATE book SET title = &#039;When Im Gone&#039; WHERE id= 1
2168
+ await BookModel.update({title: &#039;When Im Gone&#039;}, {where: {id: 1}});
2224
2169
 
2225
- // DELETE FROM user WHERE id= 1
2226
- await UserModel.destroy({where: {id: 1}});</code></pre>
2170
+ // DELETE FROM book WHERE id= 1
2171
+ await BookModel.destroy({where: {id: 1}});</code></pre>
2227
2172
  </div>
2228
2173
  <div class="tab-pane fade" id="model-accessing-cjs">
2229
- <pre><code class="js">const UserModel = require(&#039;../models/UserModel&#039;);
2174
+ <pre><code class="js">const BookModel = require(&#039;../models/BookModel&#039;);
2230
2175
 
2231
- // INSERT INTO user (email, name) VALUES (&#039;robin@example.com&#039;, &#039;Robin&#039;)
2232
- await UserModel.create({email: &#039;robin@example.com&#039;, name: &#039;Robin&#039;});
2176
+ // INSERT INTO book (title) VALUES (&#039;When Im Gone&#039;)
2177
+ await BookModel.create({title: &#039;When Im Gone&#039;});
2233
2178
 
2234
- // SELECT * FROM user
2235
- await UserModel.findAll();
2179
+ // SELECT * FROM book
2180
+ await BookModel.findAll();
2236
2181
 
2237
- // UPDATE user SET name = &#039;Taylor&#039; WHERE id= 1
2238
- await UserModel.update({name: &#039;Taylor&#039;}, {where: {id: 1}});
2182
+ // UPDATE book SET title = &#039;When Im Gone&#039; WHERE id= 1
2183
+ await BookModel.update({title: &#039;When Im Gone&#039;}, {where: {id: 1}});
2239
2184
 
2240
- // DELETE FROM user WHERE id= 1
2241
- await UserModel.destroy({where: {id: 1}});</code></pre>
2185
+ // DELETE FROM book WHERE id= 1
2186
+ await BookModel.destroy({where: {id: 1}});</code></pre>
2242
2187
  </div>
2243
2188
  </div>
2244
2189
  </div>
@@ -2521,65 +2466,65 @@ module.exports = class extends Model {
2521
2466
  </ul>
2522
2467
  <div class="tab-content">
2523
2468
  <div class="tab-pane fade show active" id="model-op-esm">
2524
- <pre><code class="js">import UserModel from &#39;../models/UserModel&#39;;
2469
+ <pre><code class="js">import BookModel from &#39;../models/BookModel&#39;;
2525
2470
 
2526
- // SELECT * FROM user WHERE email = &#39;robin@example.com&#39; AND password = &#39;password&#39;;
2527
- UserModel.findOne({
2471
+ // SELECT * FROM book WHERE title = &#39;When Im Gone&#39; AND genre = &#39;Nonfiction&#39;;
2472
+ BookModel.findOne({
2528
2473
  where: {
2529
- [UserModel.Op.and]: [
2530
- {email: &#39;robin@example.com&#39;},
2531
- {password: &#39;password&#39;}
2474
+ [BookModel.Op.and]: [
2475
+ {title: &#39;When Im Gone&#39;},
2476
+ {genre: &#39;Nonfiction&#39;}
2532
2477
  ]
2533
2478
  }
2534
2479
  });
2535
2480
 
2536
- // SELECT * FROM user WHERE name = &#39;Robin&#39; OR name = &#39;Taylor&#39;;
2537
- UserModel.findAll({
2481
+ // SELECT * FROM book WHERE title = &#39;When Im Gone&#39; OR title = &#39;Lose Yourself&#39;;
2482
+ BookModel.findAll({
2538
2483
  where: {
2539
- [UserModel.Op.or]: [
2540
- {name: &#39;Robin&#39;},
2541
- {name: &#39;Taylor&#39;}
2484
+ [BookModel.Op.or]: [
2485
+ {title: &#39;When Im Gone&#39;},
2486
+ {title: &#39;Lose Yourself&#39;}
2542
2487
  ]
2543
2488
  }
2544
2489
  });
2545
2490
 
2546
- // DELETE FROM user WHERE name = &#39;Robin&#39; OR name = &#39;Taylor&#39;;
2547
- UserModel.destroy({
2491
+ // DELETE FROM user WHERE name = &#39;When Im Gone&#39; OR name = &#39;Lose Yourself&#39;;
2492
+ BookModel.destroy({
2548
2493
  where: {
2549
- name: {
2550
- [UserModel.Op.or]: [&#39;Robin&#39;, &#39;Taylor&#39;]
2494
+ title: {
2495
+ [BookModel.Op.or]: [&#39;When Im Gone&#39;, &#39;Lose Yourself&#39;]
2551
2496
  }
2552
2497
  }
2553
2498
  });</code></pre>
2554
2499
  </div>
2555
2500
  <div class="tab-pane fade" id="model-op-cjs">
2556
- <pre><code class="js">const UserModel = require(&#39;../models/UserModel&#39;);
2501
+ <pre><code class="js">const BookModel = require(&#39;../models/BookModel&#39;);
2557
2502
 
2558
- // SELECT * FROM user WHERE email = &#39;robin@example.com&#39; AND password = &#39;password&#39;;
2559
- UserModel.findOne({
2503
+ // SELECT * FROM book WHERE title = &#39;When Im Gone&#39; AND genre = &#39;Nonfiction&#39;;
2504
+ BookModel.findOne({
2560
2505
  where: {
2561
- [UserModel.Op.and]: [
2562
- {email: &#39;robin@example.com&#39;},
2563
- {password: &#39;password&#39;}
2506
+ [BookModel.Op.and]: [
2507
+ {title: &#39;When Im Gone&#39;},
2508
+ {genre: &#39;Nonfiction&#39;}
2564
2509
  ]
2565
2510
  }
2566
2511
  });
2567
2512
 
2568
- // SELECT * FROM user WHERE name = &#39;Robin&#39; OR name = &#39;Taylor&#39;;
2569
- UserModel.findAll({
2513
+ // SELECT * FROM book WHERE title = &#39;When Im Gone&#39; OR title = &#39;Lose Yourself&#39;;
2514
+ BookModel.findAll({
2570
2515
  where: {
2571
- [UserModel.Op.or]: [
2572
- {name: &#39;Robin&#39;},
2573
- {name: &#39;Taylor&#39;}
2516
+ [BookModel.Op.or]: [
2517
+ {title: &#39;When Im Gone&#39;},
2518
+ {title: &#39;Lose Yourself&#39;}
2574
2519
  ]
2575
2520
  }
2576
2521
  });
2577
2522
 
2578
- // DELETE FROM user WHERE name = &#39;Robin&#39; OR name = &#39;Taylor&#39;;
2579
- UserModel.destroy({
2523
+ // DELETE FROM user WHERE name = &#39;When Im Gone&#39; OR name = &#39;Lose Yourself&#39;;
2524
+ BookModel.destroy({
2580
2525
  where: {
2581
- name: {
2582
- [UserModel.Op.or]: [&#39;Robin&#39;, &#39;Taylor&#39;]
2526
+ title: {
2527
+ [BookModel.Op.or]: [&#39;When Im Gone&#39;, &#39;Lose Yourself&#39;]
2583
2528
  }
2584
2529
  }
2585
2530
  });</code></pre>
@@ -2619,9 +2564,9 @@ const books = await BookModel.findAll({
2619
2564
  });
2620
2565
 
2621
2566
  // Output: books= [
2622
- // { title: 'MOBY DICK' },
2623
- // { title: 'GET RICH REALLY FAST' },
2624
- // { title: 'FINDING INNER PEACE' }
2567
+ // {title: 'MOBY DICK'},
2568
+ // {title: 'GET RICH REALLY FAST'},
2569
+ // {title: 'FINDING INNER PEACE'}
2625
2570
  // ]
2626
2571
  console.log('books=', books);</code></pre>
2627
2572
  </div>
@@ -2637,9 +2582,9 @@ const books = await BookModel.findAll({
2637
2582
  });
2638
2583
 
2639
2584
  // Output: books= [
2640
- // { title: &#39;MOBY DICK&#39; },
2641
- // { title: &#39;GET RICH REALLY FAST&#39; },
2642
- // { title: &#39;FINDING INNER PEACE&#39; }
2585
+ // {title: &#39;MOBY DICK&#39;},
2586
+ // {title: &#39;GET RICH REALLY FAST&#39;},
2587
+ // {title: &#39;FINDING INNER PEACE&#39;}
2643
2588
  // ]
2644
2589
  console.log(&#39;books=&#39;, books);</code></pre>
2645
2590
  </div>
@@ -2691,9 +2636,8 @@ const books = await BookModel.findAll({
2691
2636
  });
2692
2637
 
2693
2638
  // Output: books= [
2694
- // { id: 1, title: &#39;Moby Dick&#39;, count: 2 },
2695
- // { id: 2, title: &#39;Get Rich Really Fast&#39;, count: 1 },
2696
- // { id: 3, title: &#39;Finding Inner Peace&#39;, count: 0 }
2639
+ // {id: 1, title: &#39;When Im Gone&#39;, count: 2},
2640
+ // {id: 2, title: &#39;Lose Yourself&#39;, count: 1}
2697
2641
  // ]
2698
2642
  console.log(&#39;books=&#39;, books);</code></pre>
2699
2643
  </div>
@@ -2716,9 +2660,8 @@ const books = await BookModel.findAll({
2716
2660
  });
2717
2661
 
2718
2662
  // Output: books= [
2719
- // { id: 1, title: &#39;Moby Dick&#39;, count: 2 },
2720
- // { id: 2, title: &#39;Get Rich Really Fast&#39;, count: 1 },
2721
- // { id: 3, title: &#39;Finding Inner Peace&#39;, count: 0 }
2663
+ // {id: 1, title: &#39;When Im Gone&#39;, count: 2},
2664
+ // {id: 2, title: &#39;Lose Yourself&#39;, count: 1}
2722
2665
  // ]
2723
2666
  console.log(&#39;books=&#39;, books);</code></pre>
2724
2667
  </div>
@@ -2734,7 +2677,7 @@ console.log(&#39;books=&#39;, books);</code></pre>
2734
2677
  The attr can either be an object taken from Model.rawAttributes (for example Model.rawAttributes.id or Model.rawAttributes.name).<br>
2735
2678
  The attribute should be defined in your model definition.<br>
2736
2679
  The attribute can also be an object from one of the sequelize utility functions (sequelize.fn, sequelize.col etc.)<br>
2737
- For string attributes, use the regular { where: { attr: something }} syntax.<br>
2680
+ For string attributes, use the regular {where: {attr: something}} syntax.<br>
2738
2681
  If you don't want your string to be escaped, use sequelize.literal.<br>
2739
2682
  See <a href="https://sequelize.org/master/class/lib/sequelize.js~Sequelize.html#static-method-where" target="_blank">here</a> for details.
2740
2683
  </p>
@@ -2761,7 +2704,7 @@ const books = await BookModel.findAll({
2761
2704
  raw: true
2762
2705
  });
2763
2706
 
2764
- // Output: books= [ { title: &#39;Moby Dick&#39; } ]
2707
+ // Output: books= [{title: &#39;When Im Gone&#39;}]
2765
2708
  console.log(&#39;books=&#39;, books);</code></pre>
2766
2709
  </div>
2767
2710
  <div class="tab-pane fade" id="model-where-cjs">
@@ -2777,7 +2720,7 @@ const books = await BookModel.findAll({
2777
2720
  raw: true
2778
2721
  });
2779
2722
 
2780
- // Output: books= [ { title: &#39;Moby Dick&#39; } ]
2723
+ // Output: books= [{title: &#39;When Im Gone&#39;}]
2781
2724
  console.log(&#39;books=&#39;, books);</code></pre>
2782
2725
  </div>
2783
2726
  </div>
@@ -2791,6 +2734,19 @@ console.log(&#39;books=&#39;, books);</code></pre>
2791
2734
  See <a href="https://sequelize.org/master/variable/index.html#static-variable-QueryTypes" target="_blank">here</a> for details.
2792
2735
  </td>
2793
2736
  </tr>
2737
+ <tr>
2738
+ <td class="min-w-300px text-primary fw-bolder">public static readonly Transaction: (typeof <a href="https://sequelize.org/master/class/lib/transaction.js~Transaction.html" target="_blank">sequelize.Transaction</a>)</td>
2739
+ <td class="min-w-200px w-100">
2740
+ Reference to <a href="https://sequelize.org/master/class/lib/transaction.js~Transaction.html" target="_blank">sequelize.Transaction</a>.<br>
2741
+ This includes properties such as isolation level enums used with the transaction option.<br>
2742
+ See <a href="https://sequelize.org/master/class/lib/transaction.js~Transaction.html" target="_blank">here</a> for details.
2743
+ <pre><code class="js">const BookModel = require(&#39;../models/BookModel&#39;);
2744
+ BookModel.Transaction.ISOLATION_LEVELS.READ_UNCOMMITTED // &quot;READ UNCOMMITTED&quot;
2745
+ BookModel.Transaction.ISOLATION_LEVELS.READ_COMMITTED // &quot;READ COMMITTED&quot;
2746
+ BookModel.Transaction.ISOLATION_LEVELS.REPEATABLE_READ // &quot;REPEATABLE READ&quot;
2747
+ BookModel.Transaction.ISOLATION_LEVELS.SERIALIZABLE // &quot;SERIALIZABLE&quot;</code></pre>
2748
+ </td>
2749
+ </tr>
2794
2750
  </tbody>
2795
2751
  </table>
2796
2752
 
@@ -2859,13 +2815,17 @@ module.exports = class extends Model {
2859
2815
  </td>
2860
2816
  </tr>
2861
2817
  <tr>
2862
- <td class="min-w-300px text-primary fw-bolder">public static async begin(): Promise&lt;<a href="https://sequelize.org/master/class/lib/transaction.js~Transaction.html" target="_blank">sequelize.Transaction</a>&gt;</td>
2818
+ <td class="min-w-300px text-primary fw-bolder">public static async begin(opts?: sequelize.TransactionOptions): Promise&lt;<a href="https://sequelize.org/master/class/lib/transaction.js~Transaction.html" target="_blank">sequelize.Transaction</a>&gt;</td>
2863
2819
  <td class="min-w-200px w-100">
2864
2820
  <p>
2865
2821
  Starts a transaction and returns a transaction object to identify the running transaction.<br>
2866
2822
  This is an alias for the <code>"sequelize.Sequelize.transaction()"</code> method.<br>
2867
2823
  See <a href="https://sequelize.org/master/class/lib/sequelize.js~Sequelize.html#instance-method-transaction" target="_blank">here</a> and <a href="https://sequelize.org/master/class/lib/transaction.js~Transaction.html" target="_blank">here</a> for more information.
2868
2824
  </p>
2825
+ <p class="fw-bolder mb-0">Params:</p>
2826
+ <ul>
2827
+ <li>{sequelize.TransactionOptions} opts? Options provided when the transaction is created..</li>
2828
+ </ul>
2869
2829
  <p class="fw-bolder mb-0">Return:</p>
2870
2830
  <p>{Promise&lt;sequelize.Transaction&gt;} Returns a transaction object to identify the transaction being executed.</p>
2871
2831
  <p class="fw-bolder mb-0">Example:</p>
@@ -2880,49 +2840,74 @@ module.exports = class extends Model {
2880
2840
  </ul>
2881
2841
  <div class="tab-content">
2882
2842
  <div class="tab-pane fade show active" id="model-begin-esm">
2883
- <pre><code class="js">import UserModel from &#039;../models/UserModel&#039;;
2884
-
2843
+ <pre><code class="js">import BookModel from &#039;../models/BookModel&#039;;
2844
+
2845
+ // Simple transaction usage example.
2885
2846
  let transaction;
2886
2847
  try {
2887
- // START TRANSACTION;
2888
- transaction = await UserModel.begin();
2889
-
2890
- // SELECT `id`, `email`, `password`, `name`, `created`, `modified` FROM `user` AS `user` WHERE `user`.`id` = 1;
2891
- const user = await UserModel.findOne({where: {id: 1}}, {transaction});
2892
- user.name = &#039;Jane&#039;;
2893
-
2894
- // UPDATE `user` SET `name`=? WHERE `id` = ?
2895
- await user.save({transaction});
2848
+ transaction = await BookModel.begin();
2849
+ const book = await BookModel.create({title: &#039;When Im Gone&#039;}, {transaction});
2850
+ await transaction.commit();
2851
+ } catch(error) {
2852
+ if (transaction)
2853
+ await transaction.rollback();
2854
+ }
2896
2855
 
2897
- // COMMIT;
2856
+ // You can also use transaction options.
2857
+ let transaction;
2858
+ try {
2859
+ transaction = await BookModel.begin({
2860
+ isolationLevel: BookModel.Transaction.ISOLATION_LEVELS.REPEATABLE_READ,
2861
+ type: BookModel.Transaction.TYPES.DEFERRED,
2862
+ });
2863
+ const book = await BookModel.findOne({where: {id: 1}}, {transaction});
2864
+ book.title = &#039;When Im Gone&#039;;
2865
+ await book.save({transaction});
2898
2866
  await transaction.commit();
2899
- } catch(e) {
2900
- // ROLLBACK;
2901
- await transaction.rollback();
2867
+
2868
+ // Check the update result.
2869
+ // Output: New title of book: When Im Gone
2870
+ await book.reload();
2871
+ console.log(`New title of book: ${book.title}`);
2872
+ } catch (err) {
2873
+ if (transaction)
2874
+ await transaction.rollback();
2902
2875
  }</code></pre>
2903
2876
  </div>
2904
2877
  <div class="tab-pane fade" id="model-begin-cjs">
2905
- <pre><code class="js">const UserModel = require(&#039;../models/UserModel&#039;);
2878
+ <pre><code class="js">const BookModel = require(&#039;../models/BookModel&#039;);
2906
2879
 
2880
+ // Simple transaction usage example.
2907
2881
  let transaction;
2908
2882
  try {
2909
- // START TRANSACTION;
2910
- transaction = await UserModel.begin();
2911
-
2912
- // SELECT `id`, `email`, `password`, `name`, `created`, `modified` FROM `user` AS `user` WHERE `user`.`id` = 1;
2913
- const user = await UserModel.findOne({where: {id: 1}}, {transaction});
2914
- user.name = &#039;Jane&#039;;
2915
-
2916
- // UPDATE `user` SET `name`=? WHERE `id` = ?
2917
- await user.save({transaction});
2918
-
2919
- // COMMIT;
2883
+ transaction = await BookModel.begin();
2884
+ const book = await BookModel.create({title: &#039;When Im Gone&#039;}, {transaction});
2920
2885
  await transaction.commit();
2921
- } catch(e) {
2922
- // ROLLBACK;
2923
- await transaction.rollback();
2886
+ } catch(error) {
2887
+ if (transaction)
2888
+ await transaction.rollback();
2924
2889
  }
2925
- </code></pre>
2890
+
2891
+ // You can also use transaction options.
2892
+ let transaction;
2893
+ try {
2894
+ transaction = await BookModel.begin({
2895
+ isolationLevel: BookModel.Transaction.ISOLATION_LEVELS.REPEATABLE_READ,
2896
+ type: BookModel.Transaction.TYPES.DEFERRED,
2897
+ });
2898
+ const book = await BookModel.findOne({where: {id: 1}}, {transaction});
2899
+ book.title = &#039;When Im Gone&#039;;
2900
+ await book.save({transaction});
2901
+ await transaction.commit();
2902
+
2903
+ // Check the update result.
2904
+ // Output: New title of book: When Im Gone
2905
+ await book.reload();
2906
+ console.log(`New title of book: ${book.title}`);
2907
+ } catch (err) {
2908
+ if (transaction)
2909
+ await transaction.rollback();
2910
+ }</code></pre>
2926
2911
  </div>
2927
2912
  </div>
2928
2913
  </div>
@@ -2954,16 +2939,16 @@ try {
2954
2939
  </ul>
2955
2940
  <div class="tab-content">
2956
2941
  <div class="tab-pane fade show active" id="model-create-esm">
2957
- <pre><code class="js">import UserModel from &#039;../models/UserModel&#039;;
2942
+ <pre><code class="js">import BookModel from &#039;../models/BookModel&#039;;
2958
2943
 
2959
- // INSERT INTO `user` (`id`,`email`,`password`,`name`) VALUES (DEFAULT,&#039;ellen@example.com&#039;,&#039;password&#039;,&#039;Ellen&#039;);
2960
- await UserModel.create({email: &#039;ellen@example.com&#039;, password: &#039;password&#039;, name: &#039;Ellen&#039;});</code></pre>
2944
+ // INSERT INTO `book` (`id`,`title`) VALUES (DEFAULT,&#039;When Im Gone&#039;);
2945
+ await BookModel.create({title: &#039;When Im Gone&#039;});</code></pre>
2961
2946
  </div>
2962
2947
  <div class="tab-pane fade" id="model-create-cjs">
2963
- <pre><code class="js">const UserModel = require(&#039;../models/UserModel&#039;);
2948
+ <pre><code class="js">const BookModel = require(&#039;../models/BookModel&#039;);
2964
2949
 
2965
- // INSERT INTO `user` (`id`,`email`,`password`,`name`) VALUES (DEFAULT,&#039;ellen@example.com&#039;,&#039;password&#039;,&#039;Ellen&#039;);
2966
- await UserModel.create({email: &#039;ellen@example.com&#039;, password: &#039;password&#039;, name: &#039;Ellen&#039;});</code></pre>
2950
+ // INSERT INTO `book` (`id`,`title`) VALUES (DEFAULT,&#039;When Im Gone&#039;);
2951
+ await BookModel.create({title: &#039;When Im Gone&#039;});</code></pre>
2967
2952
  </div>
2968
2953
  </div>
2969
2954
  </div>
@@ -2994,26 +2979,26 @@ await UserModel.create({email: &#039;ellen@example.com&#039;, password: &#039;pa
2994
2979
  </ul>
2995
2980
  <div class="tab-content">
2996
2981
  <div class="tab-pane fade show active" id="model-save-esm">
2997
- <pre><code class="js">import UserModel from &#039;../models/UserModel&#039;;
2982
+ <pre><code class="js">import BookModel from &#039;../models/BookModel&#039;;
2998
2983
 
2999
- // INSERT INTO `user` (`id`,`email`,`password`,`name`) VALUES (DEFAULT,&#039;jane@example.com&#039;,&#039;password&#039;,&#039;Jane&#039;);
3000
- const user = UserModel.build({email: &#039;jane@example.com&#039;, password: &#039;password&#039;, name: &#039;Jane&#039;});
3001
- await user.save();
2984
+ // INSERT INTO `book` (`id`,`title`) VALUES (DEFAULT,&#039;When Im Gone&#039;);
2985
+ const book = BookModel.build({title: &#039;When Im Gone&#039;});
2986
+ await book.save();
3002
2987
 
3003
- // UPDATE `user` SET `name`=&#039;Ada&#039; WHERE `id` = 1;
3004
- user.name = &#039;Ada&#039;;
3005
- await user.save();</code></pre>
2988
+ // UPDATE `book` SET `title`=&#039;Lose Yourself&#039; WHERE `id` = 1;
2989
+ book.title = &#039;Lose Yourself&#039;;
2990
+ await book.save();</code></pre>
3006
2991
  </div>
3007
2992
  <div class="tab-pane fade" id="model-save-cjs">
3008
- <pre><code class="js">const UserModel = require(&#039;../models/UserModel&#039;);
2993
+ <pre><code class="js">const BookModel = require(&#039;../models/BookModel&#039;);
3009
2994
 
3010
- // INSERT INTO `user` (`id`,`email`,`password`,`name`) VALUES (DEFAULT,'jane@example.com','password','Jane');
3011
- const user = UserModel.build({email: 'jane@example.com', password: 'password', name: 'Jane'});
3012
- await user.save();
2995
+ // INSERT INTO `book` (`id`,`title`) VALUES (DEFAULT,&#039;When Im Gone&#039;);
2996
+ const book = BookModel.build({title: &#039;When Im Gone&#039;});
2997
+ await book.save();
3013
2998
 
3014
- // UPDATE `user` SET `name`='Ada' WHERE `id` = 1;
3015
- user.name = 'Ada';
3016
- await user.save();</code></pre>
2999
+ // UPDATE `book` SET `title`=&#039;Lose Yourself&#039; WHERE `id` = 1;
3000
+ book.title = &#039;Lose Yourself&#039;;
3001
+ await book.save();</code></pre>
3017
3002
  </div>
3018
3003
  </div>
3019
3004
  </div>
@@ -3045,16 +3030,16 @@ await user.save();</code></pre>
3045
3030
  </ul>
3046
3031
  <div class="tab-content">
3047
3032
  <div class="tab-pane fade show active" id="model-find-one-esm">
3048
- <pre><code class="js">import UserModel from &#039;../models/UserModel&#039;;
3033
+ <pre><code class="js">import BookModel from &#039;../models/BookModel&#039;;
3049
3034
 
3050
- // SELECT `id`, `email`, `password`, `name`, `created`, `modified` FROM `user` AS `user` LIMIT 1;
3051
- await UserModel.findOne();</code></pre>
3035
+ // SELECT `id`, `title`, `created`, `modified` FROM `book` AS `book` LIMIT 1;
3036
+ await BookModel.findOne();</code></pre>
3052
3037
  </div>
3053
3038
  <div class="tab-pane fade" id="model-find-one-cjs">
3054
- <pre><code class="js">const UserModel = require(&#039;../models/UserModel&#039;);
3039
+ <pre><code class="js">const BookModel = require(&#039;../models/BookModel&#039;);
3055
3040
 
3056
- // SELECT `id`, `email`, `password`, `name`, `created`, `modified` FROM `user` AS `user` LIMIT 1;
3057
- await UserModel.findOne();</code></pre>
3041
+ // SELECT `id`, `title`, `created`, `modified` FROM `book` AS `book` LIMIT 1;
3042
+ await BookModel.findOne();</code></pre>
3058
3043
  </div>
3059
3044
  </div>
3060
3045
  </div>
@@ -3085,25 +3070,25 @@ await UserModel.findOne();</code></pre>
3085
3070
  </ul>
3086
3071
  <div class="tab-content">
3087
3072
  <div class="tab-pane fade show active" id="model-find-all-esm">
3088
- <pre><code class="js">import UserModel from &#039;../models/UserModel&#039;;
3073
+ <pre><code class="js">import BookModel from &#039;../models/BookModel&#039;;
3089
3074
 
3090
- // SELECT `id`, `email`, `password`, `name`, `created`, `modified` FROM `user` AS `user` WHERE `user`.`name` LIKE &#039;Robin%&#039;;
3091
- const users = await UserModel.findAll({
3075
+ // SELECT `id`, `title`, `created`, `modified` FROM `book` AS `book` WHERE `book`.`title` LIKE &#039;When Im Gone%&#039;;
3076
+ await BookModel.findAll({
3092
3077
  where: {
3093
- name: {
3094
- [UserModel.Op.like]: &#039;Robin%&#039;
3078
+ title: {
3079
+ [BookModel.Op.like]: &#039;When Im Gone%&#039;
3095
3080
  }
3096
3081
  }
3097
3082
  });</code></pre>
3098
3083
  </div>
3099
3084
  <div class="tab-pane fade" id="model-find-all-cjs">
3100
- <pre><code class="js">const UserModel = require(&#039;../models/UserModel&#039;);
3085
+ <pre><code class="js">const BookModel = require(&#039;../models/BookModel&#039;);
3101
3086
 
3102
- // SELECT `id`, `email`, `password`, `name`, `created`, `modified` FROM `user` AS `user` WHERE `user`.`name` LIKE &#039;Robin%&#039;;
3103
- const users = await UserModel.findAll({
3087
+ // SELECT `id`, `title`, `created`, `modified` FROM `book` AS `book` WHERE `book`.`title` LIKE &#039;When Im Gone%&#039;;
3088
+ await BookModel.findAll({
3104
3089
  where: {
3105
- name: {
3106
- [UserModel.Op.like]: &#039;Robin%&#039;
3090
+ title: {
3091
+ [BookModel.Op.like]: &#039;When Im Gone%&#039;
3107
3092
  }
3108
3093
  }
3109
3094
  });</code></pre>
@@ -3137,16 +3122,16 @@ const users = await UserModel.findAll({
3137
3122
  </ul>
3138
3123
  <div class="tab-content">
3139
3124
  <div class="tab-pane fade show active" id="model-count-esm">
3140
- <pre><code class="js">import UserModel from &#039;../models/UserModel&#039;;
3125
+ <pre><code class="js">import BookModel from &#039;../models/BookModel&#039;;
3141
3126
 
3142
- // SELECT count(*) AS `count` FROM `user` AS `user`;
3143
- await UserModel.count();</code></pre>
3127
+ // SELECT count(*) AS `count` FROM `book` AS `book`;
3128
+ await BookModel.count();</code></pre>
3144
3129
  </div>
3145
3130
  <div class="tab-pane fade" id="model-count-cjs">
3146
- <pre><code class="js">const UserModel = require(&#039;../models/UserModel&#039;);
3131
+ <pre><code class="js">const BookModel = require(&#039;../models/BookModel&#039;);
3147
3132
 
3148
- // SELECT count(*) AS `count` FROM `user` AS `user`;
3149
- await UserModel.count();</code></pre>
3133
+ // SELECT count(*) AS `count` FROM `book` AS `book`;
3134
+ await BookModel.count();</code></pre>
3150
3135
  </div>
3151
3136
  </div>
3152
3137
  </div>
@@ -3178,22 +3163,16 @@ await UserModel.count();</code></pre>
3178
3163
  </ul>
3179
3164
  <div class="tab-content">
3180
3165
  <div class="tab-pane fade show active" id="model-update-esm">
3181
- <pre><code class="js">import UserModel from &#039;../models/UserModel&#039;;
3166
+ <pre><code class="js">import BookModel from &#039;../models/BookModel&#039;;
3182
3167
 
3183
- // UPDATE `user` SET `name`=&#039;Jane&#039; WHERE `id` = 1;
3184
- await UserModel.update(
3185
- {name: &#039;Jane&#039;},
3186
- {where: {id: 1}}
3187
- );</code></pre>
3168
+ // UPDATE `book` SET `title`=&#039;Lose Yourself&#039; WHERE `id` = 1;
3169
+ await BookModel.update({title: &#039;Lose Yourself&#039;}, {where: {id: 1}});</code></pre>
3188
3170
  </div>
3189
3171
  <div class="tab-pane fade" id="model-update-cjs">
3190
- <pre><code class="js">const UserModel = require(&#039;../models/UserModel&#039;);
3172
+ <pre><code class="js">const BookModel = require(&#039;../models/BookModel&#039;);
3191
3173
 
3192
- // UPDATE `user` SET `name`=&#039;Jane&#039; WHERE `id` = 1;
3193
- await UserModel.update(
3194
- {name: &#039;Jane&#039;},
3195
- {where: {id: 1}}
3196
- );</code></pre>
3174
+ // UPDATE `book` SET `title`=&#039;Lose Yourself&#039; WHERE `id` = 1;
3175
+ await BookModel.update({title: &#039;Lose Yourself&#039;}, {where: {id: 1}});</code></pre>
3197
3176
  </div>
3198
3177
  </div>
3199
3178
  </div>
@@ -3228,26 +3207,16 @@ await UserModel.update(
3228
3207
  </ul>
3229
3208
  <div class="tab-content">
3230
3209
  <div class="tab-pane fade show active" id="model-upsert-esm">
3231
- <pre><code class="js">import UserModel from &#039;../models/UserModel&#039;;
3210
+ <pre><code class="js">import BookModel from &#039;../models/BookModel&#039;;
3232
3211
 
3233
- // INSERT INTO `user` (`email`,`password`,`name`) VALUES (?,?,?)
3234
- // ON DUPLICATE KEY UPDATE `email`=VALUES(`email`),`password`=VALUES(`password`),`name`=VALUES(`name`);
3235
- await UserModel.upsert({
3236
- email: &#039;robin@example.com&#039;,
3237
- password: &#039;password&#039;,
3238
- name: &#039;Robin&#039;
3239
- });</code></pre>
3212
+ // INSERT INTO `book` (`title`) VALUES (?) ON DUPLICATE KEY UPDATE `title`=VALUES(`title`);
3213
+ await BookModel.upsert({title: &#039;Lose Yourself&#039;});</code></pre>
3240
3214
  </div>
3241
3215
  <div class="tab-pane fade" id="model-upsert-cjs">
3242
- <pre><code class="js">const UserModel = require(&#039;../models/UserModel&#039;);
3216
+ <pre><code class="js">const BookModel = require(&#039;../models/BookModel&#039;);
3243
3217
 
3244
- // INSERT INTO `user` (`email`,`password`,`name`) VALUES (?,?,?)
3245
- // ON DUPLICATE KEY UPDATE `email`=VALUES(`email`),`password`=VALUES(`password`),`name`=VALUES(`name`);
3246
- await UserModel.upsert({
3247
- email: &#039;robin@example.com&#039;,
3248
- password: &#039;password&#039;,
3249
- name: &#039;Robin&#039;
3250
- });</code></pre>
3218
+ // INSERT INTO `book` (`title`) VALUES (?) ON DUPLICATE KEY UPDATE `title`=VALUES(`title`);
3219
+ await BookModel.upsert({title: &#039;Lose Yourself&#039;});</code></pre>
3251
3220
  </div>
3252
3221
  </div>
3253
3222
  </div>
@@ -3278,16 +3247,16 @@ await UserModel.upsert({
3278
3247
  </ul>
3279
3248
  <div class="tab-content">
3280
3249
  <div class="tab-pane fade show active" id="model-destroy-esm">
3281
- <pre><code class="js">import UserModel from &#039;../models/UserModel&#039;;
3250
+ <pre><code class="js">import BookModel from &#039;../models/BookModel&#039;;
3282
3251
 
3283
3252
  // DELETE FROM `user` WHERE `id` = 1;
3284
- await UserModel.destroy({where: {id :1}});</code></pre>
3253
+ await BookModel.destroy({where: {id :1}});</code></pre>
3285
3254
  </div>
3286
3255
  <div class="tab-pane fade" id="model-destroy-cjs">
3287
- <pre><code class="js">const UserModel = require(&#039;../models/UserModel&#039;);
3256
+ <pre><code class="js">const BookModel = require(&#039;../models/BookModel&#039;);
3288
3257
 
3289
3258
  // DELETE FROM `user` WHERE `id` = 1;
3290
- await UserModel.destroy({where: {id :1}});</code></pre>
3259
+ await BookModel.destroy({where: {id :1}});</code></pre>
3291
3260
  </div>
3292
3261
  </div>
3293
3262
  </div>
@@ -3863,11 +3832,11 @@ module.exports = class extends Model {
3863
3832
  // "books": [
3864
3833
  // {
3865
3834
  // "userId": 1,
3866
- // "title": "The Stars Tonight"
3835
+ // "title": "When Im Gone"
3867
3836
  // },
3868
3837
  // {
3869
3838
  // "userId": 1,
3870
- // "title": "A Guide to Courteous Thievery"
3839
+ // "title": "Lose Yourself"
3871
3840
  // }
3872
3841
  // ]
3873
3842
  // }
@@ -3900,11 +3869,11 @@ await UserModel.findAll({
3900
3869
  // "books": [
3901
3870
  // {
3902
3871
  // "userId": 1,
3903
- // "title": "The Stars Tonight"
3872
+ // "title": "When Im Gone"
3904
3873
  // },
3905
3874
  // {
3906
3875
  // "userId": 1,
3907
- // "title": "A Guide to Courteous Thievery"
3876
+ // "title": "Lose Yourself"
3908
3877
  // }
3909
3878
  // ]
3910
3879
  // }
@@ -3935,11 +3904,11 @@ await UserModel.findAll({
3935
3904
  <p class="fw-bolder mb-0">Example:</p>
3936
3905
  <pre><code class="js">// By default the function will return two arguments - a results array, and an object containing metadata (such as amount of affected rows, etc).
3937
3906
  // Note that since this is a raw query, the metadata are dialect specific.
3938
- const [results, metadata] = await UserModel.query(&quot;UPDATE user SET name = &#039;Beil&#039; WHERE id = 1&quot;);
3907
+ const [results, metadata] = await BookModel.query(&quot;UPDATE book SET title = &#039;Lose Yourself&#039; WHERE id = 1&quot;);
3939
3908
 
3940
3909
  // In cases where you don&#039;t need to access the metadata you can pass in a query type to tell sequelize how to format the results. For example, for a simple select query you could do:
3941
3910
  // We didn&#039;t need to destructure the result here - the results were returned directly
3942
- const users = await sequelize.query(&quot;SELECT * FROM user&quot;, {type: UserModel.QueryTypes.SELECT});</code></pre>
3911
+ await BookModel.query(&quot;SELECT * FROM book&quot;, {type: BookModel.QueryTypes.SELECT});</code></pre>
3943
3912
  </td>
3944
3913
  </tr>
3945
3914
  </tbody>
@@ -4434,11 +4403,11 @@ const client = new sweet.services.AWSRekognitionClient({
4434
4403
  try {
4435
4404
  // Creates a collection.
4436
4405
  await client.createCollection(&#039;MyCollection&#039;);
4437
- } catch (e) {
4406
+ } catch(err) {
4438
4407
  // You can get the resulting HTTP status code from the exception.
4439
- console.log(`name: ${e.name}`);
4440
- console.log(`statusCode: ${e.statusCode}`);
4441
- console.log(`message: ${e.message}`);
4408
+ console.log(`name: ${err.name}`);
4409
+ console.log(`statusCode: ${err.statusCode}`);
4410
+ console.log(`message: ${err.message}`);
4442
4411
  }</code></pre>
4443
4412
  </div>
4444
4413
  <div class="tab-pane fade" id="rekog-method-create-collection-cjs">
@@ -4453,11 +4422,11 @@ const client = new AWSRekognitionClient({
4453
4422
  try {
4454
4423
  // Creates a collection.
4455
4424
  await client.createCollection(&#039;MyCollection&#039;);
4456
- } catch (e) {
4425
+ } catch(err) {
4457
4426
  // You can get the resulting HTTP status code from the exception.
4458
- console.log(`name: ${e.name}`);
4459
- console.log(`statusCode: ${e.statusCode}`);
4460
- console.log(`message: ${e.message}`);
4427
+ console.log(`name: ${err.name}`);
4428
+ console.log(`statusCode: ${err.statusCode}`);
4429
+ console.log(`message: ${err.message}`);
4461
4430
  }</code></pre>
4462
4431
  </div>
4463
4432
  </div>
@@ -4633,11 +4602,11 @@ const faceId = await client.indexFace(&#039;MyCollection&#039;, fs.readFileSync(
4633
4602
  // message: No face was found in the image
4634
4603
  try {
4635
4604
  await client.indexFace(&#039;MyCollection&#039;, &#039;img.jpg&#039;);
4636
- } catch (e) {
4605
+ } catch(err) {
4637
4606
  // You can get the resulting HTTP status code from the exception.
4638
- console.log(`name: ${e.name}`);
4639
- console.log(`statusCode: ${e.statusCode}`);
4640
- console.log(`message: ${e.message}`);
4607
+ console.log(`name: ${err.name}`);
4608
+ console.log(`statusCode: ${err.statusCode}`);
4609
+ console.log(`message: ${err.message}`);
4641
4610
  }
4642
4611
 
4643
4612
  // If multiple faces are found in the image, throw an error.
@@ -4646,11 +4615,11 @@ try {
4646
4615
  // message: Multiple faces found in the image
4647
4616
  try {
4648
4617
  await client.indexFace(&#039;MyCollection&#039;, &#039;img.jpg&#039;);
4649
- } catch (e) {
4618
+ } catch(err) {
4650
4619
  // You can get the resulting HTTP status code from the exception.
4651
- console.log(`name: ${e.name}`);
4652
- console.log(`statusCode: ${e.statusCode}`);
4653
- console.log(`message: ${e.message}`);
4620
+ console.log(`name: ${err.name}`);
4621
+ console.log(`statusCode: ${err.statusCode}`);
4622
+ console.log(`message: ${err.message}`);
4654
4623
  }</code></pre>
4655
4624
  </div>
4656
4625
  <div class="tab-pane fade" id="rekog-method-index-face-cjs">
@@ -4678,11 +4647,11 @@ const faceId = await client.indexFace(&#039;MyCollection&#039;, fs.readFileSync(
4678
4647
  // message: No face was found in the image
4679
4648
  try {
4680
4649
  await client.indexFace(&#039;MyCollection&#039;, &#039;img.jpg&#039;);
4681
- } catch (e) {
4650
+ } catch(err) {
4682
4651
  // You can get the resulting HTTP status code from the exception.
4683
- console.log(`name: ${e.name}`);
4684
- console.log(`statusCode: ${e.statusCode}`);
4685
- console.log(`message: ${e.message}`);
4652
+ console.log(`name: ${err.name}`);
4653
+ console.log(`statusCode: ${err.statusCode}`);
4654
+ console.log(`message: ${err.message}`);
4686
4655
  }
4687
4656
 
4688
4657
  // If multiple faces are found in the image, throw an error.
@@ -4691,11 +4660,11 @@ try {
4691
4660
  // message: Multiple faces found in the image
4692
4661
  try {
4693
4662
  await client.indexFace(&#039;MyCollection&#039;, &#039;img.jpg&#039;);
4694
- } catch (e) {
4663
+ } catch(err) {
4695
4664
  // You can get the resulting HTTP status code from the exception.
4696
- console.log(`name: ${e.name}`);
4697
- console.log(`statusCode: ${e.statusCode}`);
4698
- console.log(`message: ${e.message}`);
4665
+ console.log(`name: ${err.name}`);
4666
+ console.log(`statusCode: ${err.statusCode}`);
4667
+ console.log(`message: ${err.message}`);
4699
4668
  }</code></pre>
4700
4669
  </div>
4701
4670
  </div>
@@ -5063,7 +5032,7 @@ await client.deleteFaces(&#039;MyCollection&#039;, [&#039;f7befa24-3b83-43cc-b21
5063
5032
 
5064
5033
  <script src="https://code.jquery.com/jquery-3.6.0.slim.min.js" integrity="sha256-u7e5khyithlIdTpu22PHhENmPcRdFiHRjhAuHcs05RI=" crossorigin="anonymous"></script>
5065
5034
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script>
5066
- <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/highlight.min.js"></script>
5035
+ <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/highlight.min.js"></script>
5067
5036
  <script src="scripts/docs.js"></script>
5068
5037
  </body>
5069
5038
  </html>