Refactored schema and added link model.
This commit is contained in:
@@ -24,16 +24,12 @@ export default async function handler(
|
||||
email: email,
|
||||
},
|
||||
include: {
|
||||
collections: {
|
||||
include: {
|
||||
collection: true,
|
||||
},
|
||||
},
|
||||
collections: true,
|
||||
},
|
||||
});
|
||||
|
||||
const collections = findCollection?.collections.map((e) => {
|
||||
return { id: e.collection.id, name: e.collection.name, role: e.role };
|
||||
return { id: e.id, name: e.name, createdAt: e.createdAt };
|
||||
});
|
||||
|
||||
// console.log(session?.user?.email);
|
||||
|
||||
@@ -30,17 +30,17 @@ export default async function handler(
|
||||
where: {
|
||||
email,
|
||||
},
|
||||
include: {
|
||||
select: {
|
||||
collections: {
|
||||
where: {
|
||||
collection: {
|
||||
name: collectionName,
|
||||
},
|
||||
name: collectionName,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
console.log(typeof session.user.id);
|
||||
|
||||
const checkIfCollectionExists = findCollection?.collections[0];
|
||||
|
||||
if (checkIfCollectionExists) {
|
||||
@@ -69,12 +69,7 @@ export default async function handler(
|
||||
collections: {
|
||||
create: [
|
||||
{
|
||||
role: "owner",
|
||||
collection: {
|
||||
create: {
|
||||
name: collectionName,
|
||||
},
|
||||
},
|
||||
name: collectionName,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user