Sequlize sorts by custom field

let pets=await ctx.model.Pet.findAndCount({
            offset:offset,
            limit:query.limit,
            order: [
                [ctx.model.User,ctx.model.Shop,"userId","ASC"],
                ["createdAt", "DESC"]
            ],
            include:[
                {
                    model:ctx.model.User,
                    as:"user",
                    include:[
                        {
                            model:ctx.model.Shop,
                            attributes:{
                                include:[
                                    // [ctx.model.fn("max",ctx.model.Sequelize.col("latitude")),"distance"]
                                    [ctx.model.fn("apart",ctx.model.Sequelize.col("latitude"),ctx.model.Sequelize.col("longitude"),2.0,2.0),"distance"]
                                ]
                            },
                        }
                    ]
                },
            ]
        });

that"s fine
but I think sorting according to shop"s custom field distance is a problem

 order: [
                [ctx.model.User,ctx.model.Shop,"distance","ASC"],
                ["createdAt", "DESC"]
            ],

report Unknown column "user- > shop.distance" in" order clause"

how can I sort by shop"s custom field distance?

Mar.28,2022

Brother, no solution

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bedaa5-31319.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bedaa5-31319.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?