wolverine
wolverine
DTDrizzle Team
Created by wolverine on 6/27/2024 in #help
Type error when seeding from a .json file
This is my drizzle schema
export const accounts = sqliteTable(
"accounts",
{
id: text("id").primaryKey().default(uuidv4()),
name: text("name").unique().notNull(),
primaryAccount: text("primary_account", { enum: ['Capital', 'Assets', 'Liabilities', 'Expenses', 'Revenue'] }).notNull(),
code: integer("code").notNull(),
parentId: text("parentId"),
isGroup: integer("is_group", { mode: 'boolean' }),
accountType: text(
"account_type",
{
enum: [
//has 23 values
]
}
),
}
)
export const accounts = sqliteTable(
"accounts",
{
id: text("id").primaryKey().default(uuidv4()),
name: text("name").unique().notNull(),
primaryAccount: text("primary_account", { enum: ['Capital', 'Assets', 'Liabilities', 'Expenses', 'Revenue'] }).notNull(),
code: integer("code").notNull(),
parentId: text("parentId"),
isGroup: integer("is_group", { mode: 'boolean' }),
accountType: text(
"account_type",
{
enum: [
//has 23 values
]
}
),
}
)
this is my seed file json schema
{
"Accounts": [
{
"name": "Test",
"primaryAccount": "Assets",
"code": "10",
"isGroup": "true",
"accountType": "Prepaid Taxes"
},
]
}
{
"Accounts": [
{
"name": "Test",
"primaryAccount": "Assets",
"code": "10",
"isGroup": "true",
"accountType": "Prepaid Taxes"
},
]
}
I am importing the json file like
import accountsData from './seed.json'
import accountsData from './seed.json'
but the enum text fields are showing errors, everything works fine when i hardcode the data. What is the correct approach for this
1 replies