commit
a8be4d8f2f
|
@ -13,6 +13,8 @@ export default async function exportData(userId: number) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
pinnedLinks: true,
|
||||||
|
whitelistedUsers: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -37,41 +37,20 @@ export default async function importFromLinkwarden(
|
||||||
for (const e of data.collections) {
|
for (const e of data.collections) {
|
||||||
e.name = e.name.trim();
|
e.name = e.name.trim();
|
||||||
|
|
||||||
const findCollection = await prisma.user.findUnique({
|
const newCollection = await prisma.collection.create({
|
||||||
where: {
|
data: {
|
||||||
id: userId,
|
owner: {
|
||||||
},
|
connect: {
|
||||||
select: {
|
id: userId,
|
||||||
collections: {
|
|
||||||
where: {
|
|
||||||
name: e.name,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
name: e.name,
|
||||||
|
description: e.description,
|
||||||
|
color: e.color,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const checkIfCollectionExists = findCollection?.collections[0];
|
createFolder({ filePath: `archives/${newCollection.id}` });
|
||||||
|
|
||||||
let collectionId = findCollection?.collections[0]?.id;
|
|
||||||
|
|
||||||
if (!checkIfCollectionExists) {
|
|
||||||
const newCollection = await prisma.collection.create({
|
|
||||||
data: {
|
|
||||||
owner: {
|
|
||||||
connect: {
|
|
||||||
id: userId,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
name: e.name,
|
|
||||||
description: e.description,
|
|
||||||
color: e.color,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
createFolder({ filePath: `archives/${newCollection.id}` });
|
|
||||||
|
|
||||||
collectionId = newCollection.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Import Links
|
// Import Links
|
||||||
for (const link of e.links) {
|
for (const link of e.links) {
|
||||||
|
@ -82,7 +61,7 @@ export default async function importFromLinkwarden(
|
||||||
description: link.description,
|
description: link.description,
|
||||||
collection: {
|
collection: {
|
||||||
connect: {
|
connect: {
|
||||||
id: collectionId,
|
id: newCollection.id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// Import Tags
|
// Import Tags
|
||||||
|
|
Ŝarĝante…
Reference in New Issue