Function: bytea()
bytea():
PgBytea
Column that stores binary strings.
Returns
Remarks
Kysely database schema type definition
ts
{
readonly __select__: Buffer | null;
readonly __insert__: Buffer | string | null | undefined;
readonly __update__: Buffer | string | null;
};
Nullability and optionality will change according to the column's constraints, generated values, and default data values.
Zod Schema
Types:
ts
{
input?: Buffer | string | null | undefined;
output?: Buffer | string | null | undefined;
}
Nullability and optionality will change according to the column's constraints, generated values, and default data values.
Validations:
- Explicit
undefined
values are rejected. - Value must be a
Buffer
,string
, ornull
.
Note: Since Buffer is a Node.js API, the schema will not coerce the input to Buffer for browser compatibility.
Example
ts
import { schema, table, bytea } from "monolayer/pg";
import { zodSchema } from "monolayer/zod";
const dbSchema = schema({
tables: {
example: table({
columns: {
image: bytea(),
},
}),
},
});
// Kysely database schema type
type DB = typeof dbSchema.infer;
// Zod Schema
const schema = zodSchema(database.tables.example);
See
PostgreSQL Docs: bytea