prisma-query
convert query params to prisma args
Examples
const routeToFindManyArgs = {
'/events?id=6&id=7': { where: { id: { in: [6, 7] } } },
'/events?_expand=guests&guests.name_like=John': {
include: {
guests: {
where: { name: { contains: 'John', mode: 'insensitive' } },
},
},
},
'/events?_expand=guests&guests.vip=bool(false)': {
include: { guests: { where: { vip: false } } },
},
'/events?hosts.every.name_like=Hitesh&_expand=hosts': {
where: {
hosts: { every: { name: { contains: 'Hitesh', mode: 'insensitive' } } },
},
include: {
hosts: true,
},
},
'/events?_expand=hosts&hosts.name_like=Hitesh': {
include: {
hosts: { where: { name: { contains: 'Hitesh', mode: 'insensitive' } } },
},
},
'/events?_expand=guests&guests.name_like=Rahul&guests.vip=bool(true)': {
include: {
guests: {
where: {
vip: true,
name: { contains: 'Rahul', mode: 'insensitive' },
},
},
},
},
'/guests?eventSignupId_ne=null': {
where: { eventSignupId: { not: null } },
},
'/eventCategories?_expand=events.hosts&_expand=events.eventMetadata': {
include: {
events: { include: { eventMetadata: true, hosts: true } },
},
},
'/events?_sort=startTime&_sort=id&_order=asc': {
orderBy: [{ startTime: 'asc' }, { id: 'asc' }],
},
'/events?_sort=duration,id&_order=desc': {
orderBy: [{ duration: 'desc' }, { id: 'asc' }],
},
'/guests?_page=2&_limit=5': { skip: 5, take: 5 },
'/guests?_start=0&_end=10': {
skip: 0,
take: 10,
},
'/events?_expand=guests&guests.fans_gt=num(21000)': {
include: { guests: { where: { fans: { gt: 21000 } } } },
},
'/guests?eventId=1&fans_gt=21000': {
where: { eventId: 1, fans: { gt: 21000 } },
},
};