update
This commit is contained in:
@@ -860,6 +860,8 @@ model FileStore {
|
||||
preview String
|
||||
size Float
|
||||
type String
|
||||
//
|
||||
content Bytes @db.ByteA
|
||||
}
|
||||
|
||||
// invoice.ts
|
||||
|
@@ -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;
|
||||
|
36
03_source/cms_backend/prisma/seeds/fileStore.ts
Normal file
36
03_source/cms_backend/prisma/seeds/fileStore.ts
Normal 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 };
|
Reference in New Issue
Block a user