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/CHANGELOG.md CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.0.13] - 2021-12-13
6
+ ### Fixed
7
+ - The model's begin method now accepts the transaction option.
8
+ See [Transaction | Sequelize](https://sequelize.org/master/class/lib/transaction.js~Transaction.html) for transaction options.
9
+ ```js
10
+ let transaction;
11
+ try {
12
+ transaction = await BookModel.begin({
13
+ isolationLevel: BookModel.Transaction.ISOLATION_LEVELS.REPEATABLE_READ,
14
+ type: BookModel.Transaction.TYPES.DEFERRED,
15
+ });
16
+ const book = await BookModel.findOne({where: {id: 1}}, {transaction});
17
+ book.title = 'When Im Gone';
18
+ await book.save({transaction});
19
+ await transaction.commit();
20
+
21
+ // Check the update result.
22
+ // Output: New title of book: When Im Gone
23
+ await book.reload();
24
+ console.log(`New title of book: ${book.title}`);
25
+ } catch (err) {
26
+ if (transaction)
27
+ await transaction.rollback();
28
+ }
29
+ ```
30
+
5
31
  ## [1.0.12] - 2021-11-16
6
32
  ### Fixed
7
33
  - Added a method to the model that can execute raw SQL.
@@ -10,11 +36,11 @@ All notable changes to this project will be documented in this file.
10
36
  ```js
11
37
  // By default the function will return two arguments - a results array, and an object containing metadata (such as amount of affected rows, etc).
12
38
  // Note that since this is a raw query, the metadata are dialect specific.
13
- const [results, metadata] = await UserModel.query("UPDATE user SET name = 'Beil' WHERE id = 1");
39
+ const [results, metadata] = await BookModel.query("UPDATE book SET title = 'When Im Gone' WHERE id = 1");
14
40
 
15
41
  // In cases where you don'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:
16
42
  // We didn't need to destructure the result here - the results were returned directly
17
- const users = await sequelize.query("SELECT * FROM user", {type: UserModel.QueryTypes.SELECT});
43
+ const users = await BookModel.query("SELECT * FROM book", {type: BookModel.QueryTypes.SELECT});
18
44
  ```
19
45
 
20
46
  ## [1.0.11] - 2021-11-10