in packages/better-auth/src/adapters/kysely-adapter/kysely-adapter.ts [89:111]
function transformValueToDB(value: any, model: string, field: string) {
if (field === "id") {
return value;
}
const { type = "sqlite" } = config || {};
let f = schema[model]?.fields[field];
if (!f) {
//@ts-expect-error - The model name can be a sanitized, thus using the custom model name, not one of the default ones.
f = Object.values(schema).find((f) => f.modelName === model)!;
}
if (
f.type === "boolean" &&
(type === "sqlite" || type === "mssql") &&
value !== null &&
value !== undefined
) {
return value ? 1 : 0;
}
if (f.type === "date" && value && value instanceof Date) {
return type === "sqlite" ? value.toISOString() : value;
}
return value;
}