Sort by smart field that includes value from a belongsTo relationship
Sort by smart field that includes value from a belongsTo relationship
Implementation
const { collection } = require('forest-express-sequelize');
const models = require('../models');
collection('orders', {
actions: [],
fields: [
{
field: 'customer email',
get: (order) =>
models.customers
.findByPk(order.customer.dataValues.id)
.then((customer) => customer.email),
isSortable: true,
},
],
segments: [],
});Last updated
Was this helpful?