How to seed custom json type

I really like drizzle-seed but I've hit a snag. I can't figure out how to seed a postgre json. I don't want the default random json data. I want to randomize the keys of my own custom json type.
3 Replies
Techpure
Techpure2w ago
@babayaga What do you mean? like for example I got
export type QuestDetails = {
Quest: string;
StartPoint: string;
MemberRequirement: MemberRequirement;
OfficialLength: OfficialLength;
Requirements: string[];
ItemsRequired: string[];
Recommended: string[];
EnemiesToDefeat: string[];
};
export type OfficialLength =
| "Very Short"
| "Short"
| "Short to Medium"
| "Medium"
| "Medium to Long"
| "Long"
| "Very Long"
| "Very Very Long";
export type MemberRequirement = "Free to Play" | "Members Only";
export type QuestDetails = {
Quest: string;
StartPoint: string;
MemberRequirement: MemberRequirement;
OfficialLength: OfficialLength;
Requirements: string[];
ItemsRequired: string[];
Recommended: string[];
EnemiesToDefeat: string[];
};
export type OfficialLength =
| "Very Short"
| "Short"
| "Short to Medium"
| "Medium"
| "Medium to Long"
| "Long"
| "Very Long"
| "Very Very Long";
export type MemberRequirement = "Free to Play" | "Members Only";
Techpure
Techpure2w ago
basically just shape your json you can even do jsonb if you want like my npc table has
export const NpcTable = app.table(
"NPCTable",
(n) => ({
id: n.integer().primaryKey().notNull(),
name: n.text().notNull(),
models: n.integer().array(),
head_models: n.integer().array(),
color_replacements: jsonb("color_replacements").$type<[number, number][]>(),
material_replacements: jsonb("material_replacements").$type<
[number, number][]
>(),
actions: jsonb("actions").$type<Actions>(),
action_cursors: jsonb("action_cursors").$type<ActionCursors>(),
location: jsonb("location").$type<NpcLocations>(),
npc_combat_level: n.integer().array(),
animation_group: n.integer().array(),
movement_capabilities: n.integer().array(),
bound_size: n.integer(),
created_at: timestamp("created_at", { withTimezone: true })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updated_at: timestamp("updated_at", { withTimezone: true })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
}),
(t) => [index("idx_npc_name").on(t.name)]
);
export const NpcTable = app.table(
"NPCTable",
(n) => ({
id: n.integer().primaryKey().notNull(),
name: n.text().notNull(),
models: n.integer().array(),
head_models: n.integer().array(),
color_replacements: jsonb("color_replacements").$type<[number, number][]>(),
material_replacements: jsonb("material_replacements").$type<
[number, number][]
>(),
actions: jsonb("actions").$type<Actions>(),
action_cursors: jsonb("action_cursors").$type<ActionCursors>(),
location: jsonb("location").$type<NpcLocations>(),
npc_combat_level: n.integer().array(),
animation_group: n.integer().array(),
movement_capabilities: n.integer().array(),
bound_size: n.integer(),
created_at: timestamp("created_at", { withTimezone: true })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updated_at: timestamp("updated_at", { withTimezone: true })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
}),
(t) => [index("idx_npc_name").on(t.name)]
);

Did you find this page helpful?