Open Ryan8765 opened 3 years ago
Not sure if you resolved this, but you probably want to change your hook from a before
to an after
.
+1, I have the same issue:
@feathersjs/express/rest Error in handler: `Cannot read properties of undefined (reading 'data')` +5ms
[...]
@feathersjs/errors GeneralError(500): Cannot read properties of undefined (reading 'data') +0ms
I can use the hook in after
instead of before
– but I thought the fastJoin
hook also handles upserts (what depopulate would handle). This isn't the case when the hook is only used in after
where results can be modified, but not what is processed in upserts.
As far as I'm aware (very happy if someone can show me I'm wrong), fastJoin only works in after hooks. It takes the data the service has loaded and uses that data to find the related items.
I personally hit issues with this when I'm looking to filter on joined data. In these cases I modify the knex query (I'm almost all in PostgresSQL) in a before hook. Other possible solutions might be: custom service where you do all querying/updating in service calls; using view tables; pre-loading data in before hooks.
Version: 5.0.6 with feathers version 4.5.11
I'm working with fastJoin and for some reason unable to get it to work. Code:
I'm using this in a before hook:
Error message:
"TypeError: Cannot read property 'data' of undefined\n at /app/node_modules/feathers-hooks-common/lib/services/fast-join.js:13:48\n at /app/node_modules/feathers-hooks-common/node_modules/@feathersjs/commons/lib/hooks.js:116:46\n at processTicksAndRejections (node:internal/process/task_queues:94:5)"