1
0
Code Issues Pull Requests Projects Releases Wiki Activity GitHub Gitee

插入数据方法抽离为 dataManager.js

This commit is contained in:
2022-10-25 16:25:23 +08:00
parent c068085385
commit 4753fd55ae
8 changed files with 185 additions and 141 deletions

View File

@@ -3,6 +3,7 @@ const path = require('path');
const requestUtils = require('../../../utils/requestUtils');
const sleepUtils = require('../../../utils/sleepUtils');
const dataManager = require('../dataManager');
const dbUtils = global.dbUtils;
@@ -63,8 +64,7 @@ async function fetch({ songId, debug = false }) {
if (typeof lyric == "undefined") {
// 这首歌爬song的时候还在但是现在不在了
// 这里数据丢了不要紧所以不加await
dbUtils.query('INSERT IGNORE INTO lyric SET ?', {
await dataManager.lyric.insert({
song_id: songId,
lyric: '',
version: -1,
@@ -73,18 +73,12 @@ async function fetch({ songId, debug = false }) {
}
let lyricInfo = {
songId: songId,
song_id: songId,
lyric: lyric.lyric,
version: lyric.version,
};
// console.log("lyricInfo", lyricInfo);
// 这里数据丢了不要紧所以不加await
dbUtils.query('INSERT IGNORE INTO lyric SET ?', {
song_id: lyricInfo.songId,
lyric: lyricInfo.lyric,
version: lyricInfo.version,
});
return lyricInfo;
await dataManager.lyric.insert(lyricInfo);
}
module.exports = {