danimiclos
danimiclos
WWasp-lang
Created by danimiclos on 5/4/2024 in #đŸ™‹questions
TypeError: Cannot read properties of undefined
Hello, I'm trying to seed my database using my action, but it's saying it cannot read the properties of undefined pointing to the entity type: /// return context.entities.TipoEPI.create(.... /// my entity in main.wasp: entity TipoEPI {=psl id Int @id @default(autoincrement()) nome String descricao String epi EPI[] psl=} /* .... */ action createTipoEPI { fn: import {createTipoEPI} from "@src/epis/actions", entities: [TipoEPI] } my code in the actions.js: export const createTipoEPI = (args, context) => { return context.entities.TipoEPI.create({ data: { nome: args.nome, descricao: args.descricao } }) } a fragment of the seeding function the calls the action: export const seedTipoEPI = async (prisma) => { const results = []; const csvFilePath = resolve(__dirname, '../../../../src/seeds/tipoepi.csv'); fs.createReadStream(csvFilePath) .pipe(csv()) .on('data', (data) => results.push(data)) .on('end', async () => { for (const item of results) { await createTipoEPI(prisma, { nome: item.type }); } console.log('Successfully seeded TipoEPI data.'); }); } I don't understant why it's saying the property is undefined if even the vscode extension was autocompleting the code the way it is. Any idea? I'm not using this action anywhere else because it only gets a huge predefined list of values to use in relation with other entities. Thanks!
33 replies