PrismaP
Prisma14mo ago
25 replies
Anas Badran

Fix a query

is there something wrong with this query, it isn't working?

  await prisma.collection.findFirst({
      where: {
        id: collectionId,
      },
      include: {
        posts: {
          take: consts.ITEMS_PER_PAGE,
          skip: (currentPage - 1) * consts.ITEMS_PER_PAGE,
          include: {
            collection: true,
          },
          where: {
            AND: [
              ...(surah
                ? [
                    {
                      extraData: {
                        path: ['surah'],
                        equals: surah,
                      },
                    },
                  ]
                : []),
              ...(verse
                ? [
                    {
                      extraData: {
                        path: ['verse'],
                        equals: verse,
                      },
                    },
                  ]
                : []),
            ],
          },
        },
      },
    })
Was this page helpful?