Hello! I am trying to get a select and I can't fin...
# orm-help
j
Hello! I am trying to get a select and I can't find a way to what I need, if anyone has an idea: Basically in my model, baseRuns have stepRuns and stepRuns have a stepId and createdAt property. I want to select baseRuns with their stepRuns, but only the last created stepRun per stepId. Is there any way to do that?
hmmm can I nest distinct and orderBy actually? that would solve it I think, going to try that
Copy code
baseRuns: {
  stepRuns: {
      distinct: ['stepId' as const],
      orderBy: {
        createdAt: 'desc' as const,
      },
      take: 1,
   }
}
Got this, but that is taking only one stepRun per baseRun, not per stepId...
n
Hey Julien 👋 Could you share your schema file and the response that you are currently getting and the response that you expect? As an alternative, you can use Raw Query as well.