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

Menu