37 lines
814 B
TypeScript
37 lines
814 B
TypeScript
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 };
|