Postgres array of IDs to record

Hi,

Assuming I have an array of IDs in a PostGres array column:

await queryRunner.query(ALTER TABLE “myTable” ADD “otherTableIds” uuid array);

Is there a way to make this play happily with Forest Admin so that I can see the records being pointed to and add new ones? Or am I obliged to use a intermediary table?

I did see the docs on Smart relationship but I see how to use them for this use case. I think I understand how I would add the code to fetch the records, but this wouldn’t help with creating new records and having them added to the array.

Hello @timothyarmes,

Thanks for your message :raised_hands:

To help you out, could you tell me:

  • What is your project name?
  • Did you generate it thanks to the forest CLI? How the native behavior of it is not working in your case (editing your array in the UI and saving it does not work properly)?

Thanks.

Hi,

I couldn’t generate it since this was an addition to an existing project, and I couldn’t see how to set up FA for this. In the end I just took the conventional approach of adding a table to manage the relationship, however if it’s actually possible I’d like to see a code example for future reference.

@timothyarmes,

I am not sure I understood correctly.
Did you manage to make it work with an intermediary table?

The intermediary table is the recommended solution here.
However, it should be possible to go without it by creating a hasMany smart relationship, but then you would need to override every related relationship routes with custom code to make every use case (get, create, delete…) work.