Cannot read 'id' from property
Hi, first ever GitHub issue being created, so please be kind: :)
I am a python programmer, so don't know Node or JS as much. I've run down the rabbit hole of trying to find solutions, but I don't know how to implement most of the suggestions to try them out.
https://stackoverflow.com/questions/67193689/node-js-typeerror-cannot-read-property-id-of-undefined
My Error:
(node:116947) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
at /home/usaspending-gpt4/.npm/_npx/cda643d17fed3bae/node_modules/ask-your-database/dist/index.js:70:188
at Array.map (--unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:116947) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
That's probably going to be this bit of code. exampleRows[tableName][column.column_name]. It sounds like it doesn't have any example rows for your table. It looks like it grabs an example row for each table by querying the table here
for (const tableName of Object.keys(tables)) {
const exampleRow = await db(tableName).first();
exampleRows[tableName] = exampleRow;
}
So I suspect your table (or one of your tables, at least) is empty and you need to insert a row for this project to work.
I find a solution to solve this problem,just change the code as below:
for (const tableName of Object.keys(tables)) {
const exampleRow = await db(tableName).first();
exampleRows[tableName] = exampleRow || {};
}