37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const client_1 = require("@prisma/client");
|
|
const prisma = new client_1.PrismaClient();
|
|
async function main() {
|
|
try {
|
|
const sourcesToUpsert = [
|
|
{
|
|
name: 'Vero',
|
|
url: 'https://pricelist.vero.com.mk/89_2.html',
|
|
logo: 'vero-logo.png',
|
|
},
|
|
{
|
|
name: 'dim',
|
|
url: 'https://dim.marketceni.mk/',
|
|
logo: 'tinex-logo.png',
|
|
},
|
|
];
|
|
const upsertedSources = await Promise.all(sourcesToUpsert.map((source) => prisma.source.upsert({
|
|
where: { name: source.name },
|
|
update: {
|
|
url: source.url,
|
|
logo: source.logo,
|
|
},
|
|
create: source,
|
|
})));
|
|
console.log('Upserted sources:', upsertedSources);
|
|
}
|
|
catch (error) {
|
|
console.error('Error:', error);
|
|
}
|
|
finally {
|
|
await prisma.$disconnect();
|
|
}
|
|
}
|
|
main();
|
|
//# sourceMappingURL=create-source.js.map
|