首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >从sql查询结果中删除[TextRow ]

从sql查询结果中删除[TextRow ]
EN

Stack Overflow用户
提问于 2020-12-23 05:14:24
回答 1查看 476关注 0票数 0

因此,我正在使用mysql数据库来保存位置的纬度和经度,查询结果如下:

[ TextRow { platitude: '34.19226000', plongitude: '-118.53556100' } ],

我想去掉TextRow,只是简单地将数组存储在一个变量中,以便通过Geolib函数传递。

我目前在数据库中以十进制的形式存储纬度和经度

代码语言:javascript
运行
复制
platitude : {
    type : DataTypes.DECIMAL(10,8),
},
plongitude : {
    type : DataTypes.DECIMAL(11,8)
},

我的目标是对查询结果使用findNeast Geolib函数

这是我目前所拥有的:

代码语言:javascript
运行
复制
const query = sequelize.query("SELECT platitude,plongitude FROM peachyPatient.registeredPractices where practiceID ='1'").then(
    function(result){
        const practices = result;

        const location = geolib.findNearest({ latitude: 52.456221, longitude: 12.63128, }, [
            practices,
            { latitude: 51.503333, longitude: -0.119722 },
            { latitude: 55.751667, longitude: 37.617778 },
            { latitude: 48.8583, longitude: 2.2945 },
            { latitude: 59.3275, longitude: 18.0675 },
            { latitude: 59.916911, longitude: 10.727567 },
            // { latitude: 52.516272, longitude: 13.377722 },
           
        ]); console.log(location);
    }
    );

当我使用console.log定位时,它只是返回我的查询结果。

文档中的geoLib函数如下所示

代码语言:javascript
运行
复制
geolib.findNearest({ latitude: 52.456221, longitude: 12.63128 }, [
    { latitude: 52.516272, longitude: 13.377722 },
    { latitude: 51.515, longitude: 7.453619 },
    { latitude: 51.503333, longitude: -0.119722 },
    { latitude: 55.751667, longitude: 37.617778 },
    { latitude: 48.8583, longitude: 2.2945 },
    { latitude: 59.3275, longitude: 18.0675 },
    { latitude: 59.916911, longitude: 10.727567 },
]);

任何关于如何澄清这一点的帮助都将不胜感激。

EN

回答 1

Stack Overflow用户

发布于 2021-03-30 03:47:49

试试这个:它应该返回对象的普通json数组,不带TextRow。

代码语言:javascript
运行
复制
var resultArray = Object.values(JSON.parse(JSON.stringify(result)))
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65415875

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档