| 1234567891011121314151617181920212223242526272829303132 |
- import mysql from "mysql2/promise"
- async function del(start, end) {
- const connection = await mysql.createConnection({
- host: "rm-bp1cj5j76a6hp1zm5yo.rwlb.rds.aliyuncs.com",
- user: "rcs",
- password: "hsDL6W@5a%F@wNA@8AP&",
- database: "rcs"
- })
- const [results, fields] = await connection.query(
- `SELECT * from task where createdAt >= '${start}' and createdAt < '${end}'`
- )
- for (let task of results) {
- const [items] = await connection.query(
- `select * from task_item where taskId = ${task.id}`
- )
- console.log(task.id, items.length)
- await connection.query(
- `delete from task_item where taskId = ${task.id}`
- )
- }
- }
- await Promise.all([
- del("2024-08-01 00:00:00", "2024-08-20 00:00:00"),
- del("2024-08-20 00:00:00", "2024-09-01 00:00:00")
- ])
- connection.end()
|