Search on a smart field with two joints
Last updated
Was this helpful?
Last updated
Was this helpful?
This example shows you how to search on a smart field which display a belongsTo smart relationship.
We have an order which belongsTo
a customer which hasOne
address.
We’ve created a Smart Relationship (delivery address)
on the order table that acts like a shortcut between the order and the address.
An admin backend running on forest-express-sequelize
This directory contains the orders.js
, customers.js
and addresses.js
files where the models are declared.
This directory contains the orders.js
file where the BelongsTo Smart Relationship delivery_address
is declared.
A belongsTo Smart Relationship is created like a Smart Field with the reference
option to indicates on which collection the Smart Relationship points to.
As for Smart Field, the search is not supported by default. So we'll have to implement the logic using Sequelize querying methods.