Closed leibowitz closed 2 years ago
replacing model
by model?.toString()
on that line triggers another error as the name includes the schema as well (public in this case):
Error: There are no resources with given id: ""public"."user"" This is the list of all registered resources you can use: ...
at AdminBro.findResource (node_modules/admin-bro/lib/admin-bro.js:249:13) at PropertyDecorator.reference (node_modules/admin-bro/lib/backend/decorators/property/property-decorator.js:94:36) at node_modules/admin-bro/lib/backend/utils/populator/populator.js:23:52 at Array.filter (<anonymous>) at populator (node_modules/admin-bro/lib/backend/utils/populator/populator.js:23:36) at Object.handler (node_modules/admin-bro/lib/backend/actions/list/list-action.js:89:59) at processTicksAndRejections (internal/process/task_queues.js:85:5) at ActionDecorator.handler (node_modules/admin-bro/lib/backend/decorators/action/action-decorator.js:73:19) at handler (node_modules/@admin-bro/express/plugin.js:59:22)
I tried using model?.tableName
instead and that seems to work
:tada: This issue has been resolved in version 2.1.2 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
I am getting errors when dealing with foreign keys defined without a reference.
Let's assume there are two tables, Post and User
User
Post
Note the references is commented out. This is by design, and is just left there to highlight how it would be defined, if necessary.
Now we define a relationship, which is totally valid in sequelize even if the references property has not been defined.
By doing this, the
this.sequelizePath.references?.model
in https://github.com/SoftwareBrothers/admin-bro-sequelizejs/blob/8e672b49095c1504782029ee4eb1d8fe9c1a61b4/src/property.ts#L76 is returning an object (even with thereturn ... as string
I'm using latest version (1.1.1) and I get this when showing what I get from
property.reference()
Which is similar to what
addSchema
is returning in sequelize, which is whatModel.getTableName
returns. Andmodel
is set to the value returned bygetTableName
. So themodel
property is not of type Model in that case.And the full error: