'Sequelize - SQL Server - Order One to Many Associations

I have a problem, I contextualize I have 3 tables 1 for the trips, 1 for the points of interest and 1 other which makes the connection between the trips and the points of interests.

When I GET the trips I get this :

Postman request - 1 Postman request - 2

My code is this one for the GET request :

include: [
  {
    model: CategoryTrips,
    as: "categories",
    attributes: ["id", "category"],
    through: {
      attributes: [],
    },
  },
  {
    model: PointOfInterest,
    as: "pointsOfInterest",
    attributes: [
      "id",
      "title",
      "description",
      "photo",
      "website",
      "practicalinfo",
      "address",
      "city",
      "zipcode",
      "latitude",
      "longitude",
    ],
    // include: [{
    //   model: PointTrip,
    //   as: "pointTrip",
    //   separate: true,
    //   order: [["rank", "ASC"]],
    // }],
  },
  {
    model: Client,
    as: "client",
    attributes: ["id", "storeName", "website"],
  },
  {
    model: Picture,
    as: "pictures",
    attributes: ["id", "path"],
  },
],

I would like to understand how it is possible to sort the points of interest in the trips query from the association table "rank" fields

Can you help me please



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source