I am getting a wierd error in this orderBy: ``` {w...
# orm-help
d
I am getting a wierd error in this orderBy:
Copy code
{where: {
    task_type_id: type.id,
    createdAt: {
      gt: new Date(earliestInterval),
    },
  },
  orderBy: {
    createdAt: 'asc',
  },
};
src/tasks/repeat/repeat.service.ts7747 - error TS2345: Argument of type ‘{ where: { task_type_id: any; createdAt: { gt: Date; }; }; orderBy: { createdAt: string; }; }’ is not assignable to parameter of type ‘{ select?: taskSelect; include?: taskInclude; where?: taskWhereInput; orderBy?: Enumerable<taskOrderByWithRelationInput>; cursor?: taskWhereUniqueInput; take?: number; skip?: number; distinct?: Enumerable<...>; }’. Types of property ‘orderBy’ are incompatible. Type ‘{ createdAt: string; }’ is not assignable to type ‘Enumerable<taskOrderByWithRelationInput>‘. Type ‘{ createdAt: string; }’ is not assignable to type ‘taskOrderByWithRelationInput’. Types of property ‘createdAt’ are incompatible. Type ‘string’ is not assignable to type ‘SortOrder’. schema is
Copy code
model task {
  id           String       @id @default(uuid())
  type         task_type    @relation(fields: [task_type_id], references: [id])
  task_type_id String
  task_events  task_event[]
  notes        String?
  data         Json?
  createdAt    DateTime    @default(now())
  last_work_done  DateTime?
  completedAt  DateTime?
  status       String      @default("started")
  parent_task  task?       @relation(name: "parent", fields: [parent_task_id], references: [id])
  parent_task_id String?
  child_tasks  task[]      @relation(name: "parent")
}
I have also tried putting the orderBy in an array
l
sometimes i've found the TS errors to be a bit misleading. I think first you can try the actual
SortOrder.asc
as this should not register as string. But i think the root cause is that your
tast_type_id
is cast as
any
. You might need to specify the
type.id
?