console.log("a"); const fs = require('fs'); const path = require('path'); const Prisma = require("@prisma/client"); const prisma = new Prisma.PrismaClient(); console.log("processing new border images"); const cwd = process.cwd(); const folder = path.join(cwd, cwd.includes("util") ? ".." : "", "public/images"); const list = fs.readdirSync(folder); (async () => { let numAdded = 0; for (let item of list) { // console.log(item); const result = await prisma.borderImage.findFirst( { where: { imageName: item } } ); if (!result) { const added = await prisma.borderImage.create( { data: { imageName: item }, } ); numAdded++; console.log(added); } } console.log(`Processed ${numAdded} new images.`); })();