first commit

This commit is contained in:
2025-04-22 10:56:56 +07:00
commit af123c091b
147 changed files with 778063 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
import { useToString } from '@vueuse/core'
export default defineEventHandler(async (event) => {
const query = getQuery(event)
const parent = JSON.parse(query.parent)
try {
const results = await prisma.address.aggregateRaw({
pipeline: [
{ $unwind: { path: '$regencies' } },
{
$match: {
_id: parent._id,
},
},
{
$project: {
_id: '$regencies._id',
name: '$regencies.name',
},
},
],
})
return results
} catch (error) {
// Return error if fetching users fails
return {
status: 500,
body: { message: 'Failed to fetch regencies' },
}
}
})