DEV Community

Numaira Nawaz
Numaira Nawaz

Posted on

How to get an array of joined table in sequelize in findAll()

  const response = await OrderDal.findAll({
  where: { buyerId: userId }
  attributes: { exclude: ['outcomeId', 'programId'] },
  include: [
    {
      model: User,
      as: 'buyerOrders',
      attributes: ['name'],
    },
    {
      model: User,
      as: 'sellerOrders',
      attributes: ['name'],
    },
    {
      model: Outcome,
      attributes: ['title'],
    },
    {
      model: ProgramOrder,
      as: 'programOrders',
      attributes: ['orderId', 'totalUnitsValue', 'CPO', 'PPO'],

Top comments (0)