Custom Field Types
JSON-Serialized Fields
CREATE TABLE topics(
id bigserial PRIMARY KEY,
...
actors: jsonc NOT NULL
);type Actors = {
editor_ids: string[];
// will add more fields later
};
const ActorsType = {
dbValueToJs(v: unknown): Actors {
// node-postgres already parses jsonc internally,
// so we don't need anything more here
return v;
},
stringify(obj: Actors): string {
return JSON.stringify(v);
},
parse(v: string): Actors {
return JSON.parse(v);
},
}Adding an Optional Property to Custom Type
Adding a Required Property to Custom Type
Changing the Shape Significantly
Last updated