Skip to content

Select and Where types

type SelectShape = {
[field: string]: true | { as: string } | SelectShape; // nested relation
};
type WhereShape = {
[field: string]:
| Value // implicit eq
| Value[] // implicit in
| { contains?: Value; gte?: Value; lte?: Value; ... }; // operators
};
type OrderByShape = {
[field: string]: "asc" | "desc";
};
type CreateInput = {
[field: string]: Value;
// Fields with .autoCreate() are excluded
// Many-to-many relations passed as array of IDs or objects
[relation: string]: ID[] | JunctionData[];
};
type UpdateInput = {
[field: string]: Value;
// Many-to-many relations passed as array of IDs (replaces all)
};
type CursorOptions = {
select?: SelectShape;
where?: WhereShape;
orderBy: OrderByShape; // required
after?: string;
limit: number; // required
};
type PaginationOptions = {
page: number;
perPage: number;
};

.get() also accepts limit and offset as direct options for simple pagination without using pagination.

const { data } = await jsorm.users.get({ limit: 10, offset: 20 });