umami/queries/admin/website/getAllWebsites.js

24 lines
395 B
JavaScript
Raw Normal View History

2022-08-28 04:38:35 +00:00
import prisma from 'lib/prisma';
2022-07-12 21:14:36 +00:00
export async function getAllWebsites() {
2022-08-28 04:38:35 +00:00
let data = await prisma.client.website.findMany({
orderBy: [
{
userId: 'asc',
2022-08-28 04:38:35 +00:00
},
{
name: 'asc',
},
],
include: {
2022-11-01 06:42:37 +00:00
user: {
2022-08-28 04:38:35 +00:00
select: {
username: true,
2022-07-12 21:14:36 +00:00
},
},
2022-08-28 04:38:35 +00:00
},
});
2022-11-01 06:42:37 +00:00
return data.map(i => ({ ...i, user: i.user.username }));
2022-07-12 21:14:36 +00:00
}