Sort order by two fields

Hi all, I have a query like the following

    setIsFetchingProducts(true);
    const Product = Moralis.Object.extend(ProductKeys.tableName);
    const query = new Moralis.Query(Product);

    query.equalTo(ProductKeys.hiddenProduct, false);
    query.equalTo(ProductKeys.projectId, project.id);
    query.descending(ProductKeys.createdAt);

    // I want to be able to do something like query.descending(ProductKeys.featured);

    query.skip(page * perPage);
    query.limit(perPage);
    query.withCount();

where it fetches the product in descending order based on createdAt. However, I also want to prioritize the order so it fetches products that are also “featured”. How can I query and sort based on these 2 fields?

However, I also want to prioritize the order so it fetches products that are also “featured”

Can you explain this a bit more? If you want to also fetch products that are featured (like based on a featured column), then you can add another constraint to your query e.g. another equalTo.

I don’t want to limit my search of the featured column. I want to get a list of products in descending createdAt order AND products that have featured == true also take priority.

Can you give an example of how you want the final query’s results to look like? Do you want featured products in descending order first, even if it breaks the createdAt order?