美文网首页
微信小程序云数据库更新地理位置信息coordinates

微信小程序云数据库更新地理位置信息coordinates

作者: PurySun | 来源:发表于2020-02-05 15:55 被阅读0次
E0A220ECFAD87F8D6FEF6E503625FE95.png

微信小程序中云数据库中支持多种地理位置类型,对于复杂类型如MultiLineString等,当更新位置信息时,在云端不能直接取出其值操作。

举例,如图,在数据库中新增path字段,MultiLineString类型,二级索引coordinates记录坐标信息。当在云端用查询方式get获取path信息时无法直接得到coordinates数据,永远是null,不清楚是bug还是为了安全不让获取,但可以正常返回给客户端。

let result = todo.where({
    key:“2020-2-2”
}).get().then(async res = >{
    console.log(res);
    //-- coordinates此处为null
    console.log(res.data[0].path.coordinates);
}).catch(async res = >{
    return res;
});

如果想追加coordinates数据,需要用db.command里的方法更新。

  const _ = db.command;
  let pathData = [[1,1], [1,1]];
  const update = await todo.update({data: {
    'path.coordinates': _.push(pathData)
  }});
  return update;

相关文章

网友评论

      本文标题:微信小程序云数据库更新地理位置信息coordinates

      本文链接:https://www.haomeiwen.com/subject/ibusxhtx.html