mirror of
https://github.com/ArthurDanjou/website.git
synced 2026-01-14 12:14:42 +01:00
Import drizzle replacing prisma
Signed-off-by: Arthur DANJOU <arthurdanjou@outlook.fr>
This commit is contained in:
20
server/api/bookmarks.get.ts
Normal file
20
server/api/bookmarks.get.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { favorite, category } = getQuery(event)
|
||||
|
||||
const bookmarks = await useDB().query.bookmarks
|
||||
.findMany({
|
||||
orderBy: [asc(tables.talents.id)],
|
||||
with: {
|
||||
bookmarkCategories: {
|
||||
with: {
|
||||
category: true
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return bookmarks.filter(bookmark =>
|
||||
(category === 'all' || bookmark.bookmarkCategories.some(cat => cat.category.slug === category))
|
||||
&& (favorite === 'false' || bookmark.favorite)
|
||||
)
|
||||
})
|
||||
Reference in New Issue
Block a user