Skip to content

Commit

Permalink
Merge pull request #10 from lxdao-official/develop
Browse files Browse the repository at this point in the history
Fix for db upgrade
  • Loading branch information
brucexu-eth authored Jan 21, 2025
2 parents 52ade9e + 45400c0 commit 222d403
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,17 +399,26 @@ export class AppService {

async saveData(writeData: EIPs[]) {
try {
// console.log(writeData.length);
await this.prisma.eIPs.deleteMany({});
// for (const item of writeData) {
// console.log('item:', item);
// await this.prisma.eIPs.create({ data: item });
// }
await this.prisma.eIPs.createMany({
data: writeData,
});

for (const item of writeData) {
// 确保 requires 字段是数字数组
const formattedItem = {
...item,
requires: Array.isArray(item.requires)
? item.requires.map((r) =>
typeof r === 'number' ? r : parseInt(r),
)
: [],
};

await this.prisma.eIPs.create({
data: formattedItem,
});
}
} catch (err) {
console.log(err);
console.error('Error saving data:', err);
throw err;
}
}

Expand Down

0 comments on commit 222d403

Please sign in to comment.