🗃️ Write faster prisma queries
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { getLinkedTypebots } from '@/features/blocks/logic/typebotLink/api'
|
||||
import prisma from '@/lib/prisma'
|
||||
import { canReadTypebot } from '@/utils/api/dbRules'
|
||||
import { canReadTypebots } from '@/utils/api/dbRules'
|
||||
import { authenticatedProcedure } from '@/utils/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { Typebot, Webhook } from 'models'
|
||||
@@ -40,7 +40,7 @@ export const getResultExampleProcedure = authenticatedProcedure
|
||||
)
|
||||
.query(async ({ input: { typebotId, blockId }, ctx: { user } }) => {
|
||||
const typebot = (await prisma.typebot.findFirst({
|
||||
where: canReadTypebot(typebotId, user),
|
||||
where: canReadTypebots(typebotId, user),
|
||||
select: {
|
||||
groups: true,
|
||||
edges: true,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import { canReadTypebot } from '@/utils/api/dbRules'
|
||||
import { canReadTypebots } from '@/utils/api/dbRules'
|
||||
import { authenticatedProcedure } from '@/utils/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { Group, Typebot, Webhook, WebhookBlock } from 'models'
|
||||
@@ -36,7 +36,7 @@ export const listWebhookBlocksProcedure = authenticatedProcedure
|
||||
)
|
||||
.query(async ({ input: { typebotId }, ctx: { user } }) => {
|
||||
const typebot = (await prisma.typebot.findFirst({
|
||||
where: canReadTypebot(typebotId, user),
|
||||
where: canReadTypebots(typebotId, user),
|
||||
select: {
|
||||
groups: true,
|
||||
webhooks: true,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import { canWriteTypebot } from '@/utils/api/dbRules'
|
||||
import { canWriteTypebots } from '@/utils/api/dbRules'
|
||||
import { authenticatedProcedure } from '@/utils/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { Typebot, Webhook, WebhookBlock } from 'models'
|
||||
@@ -31,7 +31,7 @@ export const subscribeWebhookProcedure = authenticatedProcedure
|
||||
)
|
||||
.query(async ({ input: { typebotId, blockId, url }, ctx: { user } }) => {
|
||||
const typebot = (await prisma.typebot.findFirst({
|
||||
where: canWriteTypebot(typebotId, user),
|
||||
where: canWriteTypebots(typebotId, user),
|
||||
select: {
|
||||
groups: true,
|
||||
webhooks: true,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import prisma from '@/lib/prisma'
|
||||
import { canWriteTypebot } from '@/utils/api/dbRules'
|
||||
import { canWriteTypebots } from '@/utils/api/dbRules'
|
||||
import { authenticatedProcedure } from '@/utils/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { Typebot, Webhook, WebhookBlock } from 'models'
|
||||
@@ -30,7 +30,7 @@ export const unsubscribeWebhookProcedure = authenticatedProcedure
|
||||
)
|
||||
.query(async ({ input: { typebotId, blockId }, ctx: { user } }) => {
|
||||
const typebot = (await prisma.typebot.findFirst({
|
||||
where: canWriteTypebot(typebotId, user),
|
||||
where: canWriteTypebots(typebotId, user),
|
||||
select: {
|
||||
groups: true,
|
||||
webhooks: true,
|
||||
|
||||
Reference in New Issue
Block a user