Skip to content

Commit

Permalink
fix: db issue
Browse files Browse the repository at this point in the history
  • Loading branch information
snaildarter committed Jan 21, 2025
1 parent 45400c0 commit 2736e38
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,21 +401,9 @@ export class AppService {
try {
await this.prisma.eIPs.deleteMany({});

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,
});
}
await this.prisma.eIPs.createMany({
data: writeData,
});
} catch (err) {
console.error('Error saving data:', err);
throw err;
Expand Down

0 comments on commit 2736e38

Please sign in to comment.