Skip to content

Commit 6ef5baf

Browse files
committed
Fixed to use arrow functions for db.run where this is not used
db.run のコールバック関数内で this を使用しない箇所について、可読性向上のために function 式からアロー関数へ変更
1 parent 12973cf commit 6ef5baf

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

03.asynchronous/sqlite_callback_error.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const dropTableQuery = "DROP TABLE books";
1313

1414
const titles = ["I Am a Cat", "I Am a Cat", "SANSHIRO"];
1515

16-
db.run(createTableQuery, function () {
16+
db.run(createTableQuery, () => {
1717
console.log("Table was created successfully");
1818
db.run(insertRecordQuery, titles[0], function (err) {
1919
if (err) {
@@ -48,7 +48,7 @@ db.run(createTableQuery, function () {
4848
console.log(`id:${row.id}, title:${row.title}`);
4949
}
5050
}
51-
db.run(dropTableQuery, function () {
51+
db.run(dropTableQuery, () => {
5252
console.log("Table was deleted successfully");
5353
db.close();
5454
});

03.asynchronous/sqlite_callback_no_error.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const dropTableQuery = "DROP TABLE books";
1313

1414
const titles = ["I Am a Cat", "KOKORO", "SANSHIRO"];
1515

16-
db.run(createTableQuery, function () {
16+
db.run(createTableQuery, () => {
1717
console.log("Table was created successfully");
1818
db.run(insertRecordQuery, titles[0], function () {
1919
console.log(`Record was inserted successfully with ID: ${this.lastID}`);
@@ -26,7 +26,7 @@ db.run(createTableQuery, function () {
2626
for (const row of rows) {
2727
console.log(`id:${row.id}, title:${row.title}`);
2828
}
29-
db.run(dropTableQuery, function () {
29+
db.run(dropTableQuery, () => {
3030
console.log("Table was deleted successfully");
3131
db.close();
3232
});

0 commit comments

Comments
 (0)