-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [add] - チャンネル順序を取得できるSocketハンドラと関数作成 * [add] - チャンネル順序用のinterface追加 * [change] - コメントとログ無効化 * [fix] - リンクデータパース時のデータ判別式が間違い * [add] - チャンネル順序の上書き関数とSocketハンドラを作成
- Loading branch information
Showing
6 changed files
with
137 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import sqlite3 from "sqlite3"; | ||
const db = new sqlite3.Database("./records/USER.db"); | ||
|
||
export default async function fetchUserChannelOrder(userId: string) { | ||
try { | ||
|
||
return new Promise((resolve) => { | ||
db.all( | ||
` | ||
SELECT channelOrder FROM USERS_SAVES | ||
WHERE userId=? | ||
`, | ||
userId, | ||
(err:Error, channelOrderData:[{channelOrder: string}]) => { | ||
//console.log("fetchUserChannelOrder :: db : channelOrder->", channelOrderData); | ||
//文字列をJSONにしてから返す | ||
resolve(JSON.parse(channelOrderData[0].channelOrder)); | ||
return; | ||
} | ||
) | ||
}); | ||
|
||
} catch(e) { | ||
|
||
console.log("fetchUserChannelOrder :: エラー->", e); | ||
return null; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import sqlite3 from "sqlite3"; | ||
const db = new sqlite3.Database("./records/USER.db"); | ||
|
||
import type { IChannelOrder } from "../../type/Channel"; | ||
|
||
export default async function saveUserChannelOrder(userId:string, channelOrder:IChannelOrder) | ||
:Promise<boolean> { | ||
return new Promise((resolve) => { | ||
try { | ||
|
||
//設定データを書き込み更新 | ||
db.run( | ||
` | ||
UPDATE USERS_SAVES SET channelOrder=? | ||
WHERE userId=? | ||
` | ||
, | ||
[JSON.stringify(channelOrder), userId], | ||
(err) => { | ||
if (err) { | ||
console.log("saveUserChannelOrder :: エラー->", err); | ||
//失敗と返す | ||
resolve(false); | ||
return; | ||
} else { | ||
//成功と返す | ||
resolve(true); | ||
return; | ||
} | ||
}); | ||
|
||
} catch(e) { | ||
|
||
console.log("saveUserChannelOrder :: エラー->", e); | ||
resolve(false); | ||
return; | ||
|
||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters