feat: refs #5144 saveTable
This commit is contained in:
parent
97b778245f
commit
2a7fa0eaef
|
@ -1,5 +1,6 @@
|
||||||
import con from '../db/connect.js';
|
import con from '../db/connect.js';
|
||||||
import conMaster from '../db/connectMaster.js';
|
import conMaster from '../db/connectMaster.js';
|
||||||
|
import fs from 'node:fs';
|
||||||
|
|
||||||
export default async uniqueRead => {
|
export default async uniqueRead => {
|
||||||
const reads = new Set([
|
const reads = new Set([
|
||||||
|
@ -70,7 +71,23 @@ export default async uniqueRead => {
|
||||||
uniqueRead[3].size,
|
uniqueRead[3].size,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
await saveTable();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('LIADA', palletFk, e);
|
console.log('error debugging', palletFk, e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async function saveTable() {
|
||||||
|
const [table] = await con.query(`SELECT * FROM trys WHERE DATE(timestamp) = CURDATE()`);
|
||||||
|
const date = new Date().toISOString().split('T')[0];
|
||||||
|
if (!table.length) return;
|
||||||
|
|
||||||
|
const file = fs.createWriteStream(`${date}.txt`);
|
||||||
|
file.on('error', function(err) {
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
table.forEach(function(v) {
|
||||||
|
file.write(JSON.stringify(v) + '\n');
|
||||||
|
});
|
||||||
|
file.end();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue