API reference › @evolu/common › local‑first/Query › KyselyNotNull
type KyselyNotNull = NotNull;
Defined in: packages/common/src/local-first/Query.ts:74
Narrows a column to non-null with Kysely's $narrowType.
Queries type every column except id as nullable. After a query filters out
a column's null values, $narrowType with this type removes null from the
column's row type.
Example
import {
assertType,
createQueryBuilder,
testEvoluSchema,
type KyselyNotNull,
type NonEmptyTrimmedString100,
} from "@evolu/common";
const createQuery = createQueryBuilder(testEvoluSchema);
const allTitles = createQuery((db) =>
db.selectFrom("todo").select(["id", "title"]),
);
const titles = createQuery((db) =>
db
.selectFrom("todo")
.select(["id", "title"])
.where("title", "is not", null)
.$narrowType<{ title: KyselyNotNull }>(),
);
assertType<
[(typeof allTitles.Row)["title"], (typeof titles.Row)["title"]],
[NonEmptyTrimmedString100 | null, NonEmptyTrimmedString100]
>();