({ id: t.exposeID("id", { nullable: false }), createdAt: t" /> ({ id: t.exposeID("id", { nullable: false }), createdAt: t" /> ({ id: t.exposeID("id", { nullable: false }), createdAt: t"/>

Does pothos with prisma support groupby operations?

49 Views Asked by At

I have:

export const StockDelivery = builder.prismaObject("StockDelivery", {
  fields: (t) => ({
    id: t.exposeID("id", { nullable: false }),
    createdAt: t.expose("createdAt", { type: "DateScalar", nullable: false }),
    modifiedAt: t.expose("modifiedAt", { type: "DateScalar", nullable: false }),
    expectedAt: t.expose("expectedAt", { type: "DateScalar", nullable: false }),
    deliveredAt: t.expose("deliveredAt", { type: "DateScalar", nullable: true }),
    supplier: t.relation("supplier", { nullable: false }),
    commodity: t.relation("commodity", { nullable: false }),

    cost: t.exposeFloat("cost", { nullable: false }),
    qty: t.exposeInt("qty", { nullable: false }),
    cancelled: t.exposeBoolean("cancelled", { nullable: false }),
  }),
});

And I want to create a query called "shipments" that groups stock-deliveries by the day they are expected and supplier that is delivering them.

I know prisma has a built in prisma.stockDelivery.groupby({...}) function, but I can't figure out how to use it in conjunction with pothos.

I assume I would have to create a custom variant of the stockDelivery prismaObject, but unfortunately, the pothos docs (tiny in size) doesn't mention group by.

Is there a solution to this?

cheers.

0

There are 0 best solutions below