Closed hckhanh closed 2 years ago
in v3.3 (released yesterday :) ) - we added support for creating nested schemas. I am writing an article about that right now but this is the part about it (quote from the wip article)
Mixed properties and JSON(B)
Before v3.3 we relied totally on the adapters to handle relationships between resources (tables/collections) and nested schemas. This had lots of limitations, because: Not all ORMs handle nested schemas in JSONB fields Relationships (one to many) could be n handled only under one database And, the worst of all, we had to maintain different implementations in all the adapters.
So in v3.3 we allow users to define data structures in AdminBro. What does this mean?
Let me give you an example:
Let's say you have a JSONB property defined in sequelize:
postImage: {
type: DataTypes.JSONB,
},
Now in your ResourceOptions you can define that this particular field is mixed and have size and path:
photoImage: {
type: 'mixed',
},
'photoImage.size': {
type: 'number',
},
'photoImage.path': {
type: 'string',
},
Now you can even extend it with an… array of references (!!!) tags (where tags could relate to external API).
'photoImage.tags': {
reference: 'Tag',
isArray: true,
},
Isn't that awesome?!
The same goes with typeorm adapter.
and the article: https://wojciechkrysiak.medium.com/popular-node-js-react-admin-panel-adminbro-just-got-version-3-3-the-biggest-release-this-year-ced0a90e3431
please let me know if that helped
@wojtek-krysiak , thank you for your clear instruction. It helps me through https://github.com/SoftwareBrothers/admin-bro-sequelizejs/tree/master/example-app
Is it still possible to specify field types for JSONB fields in ResourceOptions? I can't find any documentation for how to implement what was described, and it looks like this might not be relevant anymore to the current version.
Ahh, I was able to find the documentation for ResourceOptions properties after a bit of digging and got this working.
Describe the problem feature solves I am using MySQL, JSON type column did not show correctly on the dashboard
Describe the solution you'd like At least, you can convert the JSON data to STRING