try to add image mapping
This commit is contained in:
parent
49904865eb
commit
8ed0fa5de2
7 changed files with 71 additions and 3 deletions
40
util/ingest.js
Normal file
40
util/ingest.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
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.`);
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue