Relation between data sources on different types

Screenshot 2024-12-02 at 13.16.02

Feature(s) impacted

adding a relation between two different data sources

Observed behavior

I would like to relate data between a sequelize postgres data source and a mongo db data source, but I have no control over the content structure of the mongo source. the developer decided to store the index as a string, but in our postgres database it is an integer. When I relate the 2 together, I get the error: Error: Types from ‘transcription.conversationId’ and ‘conversations_conversation.id’ do not match. This is correct, they don’t, but is there any way I can make the relation anyway? Perhaps a virtual field or similar to cast it as a string first?

Expected behavior

I would like to see the data related through the different data types.

Failure Logs

Context

  • Project name: KAI Conversations
  • Team name: Operations
  • Environment name: Development
  • Agent technology: nodejs
  • Agent (forest package) name & version: @forestadmin/agent 1.53.1
  • Database type: postgres (sequelize)
  • Recent changes made on your end if any: setting up the new agent

Hello,
Yes, you can use a “virtual field” to cast the field by using the addField helper. The following example is related to your case.

If you need further assistance, feel free to reach out!

Best regards,
Alban

Thanks very much, I stumbled across the addField function not long after I posted, it was a bit tricky because there were issues with the In operator not being supported so I needed to update that too, but it all seems to be working as expected now, thanks again.

1 Like