This commit is contained in:
louiscklaw
2025-05-28 21:06:12 +08:00
parent 4007227418
commit db805f23b6
61 changed files with 1279 additions and 494 deletions

View File

@@ -860,6 +860,8 @@ model FileStore {
preview String
size Float
type String
//
content Bytes @db.ByteA
}
// invoice.ts

View File

@@ -21,6 +21,7 @@ import { superuserSeed } from './seeds/superuser';
import { userSeed } from './seeds/user';
import { ProductReview } from './seeds/productReview';
import { ProductItem } from './seeds/productItem';
import { FileStore } from './seeds/fileStore';
//
// import { Blog } from './seeds/blog';
// import { Mail } from './seeds/mail';
@@ -34,6 +35,7 @@ import { ProductItem } from './seeds/productItem';
await superuserSeed;
await userSeed;
await ProductReview;
await FileStore;
await ProductItem;
// await Blog;
// await Mail;

View File

@@ -0,0 +1,36 @@
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
const fs = require('fs');
const content = Buffer.from(fs.readFileSync('./helloworld.txt', 'utf-8'), 'utf-8');
async function fileStore() {
for (let i = 0; i < 2 + 1; i++) {
const temp = await prisma.fileStore.upsert({
where: { id: i },
update: {},
create: {
name: 'helloworld.txt',
path: './helloworld.txt',
preview: '',
size: content.byteLength,
type: 'txt',
content: content,
},
});
}
console.log('seed fileStore done');
}
const FileStore = fileStore()
.then(async () => {
await prisma.$disconnect();
})
.catch(async (e) => {
console.error(e);
await prisma.$disconnect();
process.exit(1);
});
export { FileStore };