【发布时间】:2023-03-15 13:53:01
【问题描述】:
我创建了以 json 形式返回集合数据的 http get 服务。但我不想显示列数据类型
这是我的功能代码。
const result = doc.find({},{id:1,desc:1,label:1,LocationTree:1,path:1,coordinates:1,_id: 0}).toArray();
return result;
【问题讨论】:
我创建了以 json 形式返回集合数据的 http get 服务。但我不想显示列数据类型
这是我的功能代码。
const result = doc.find({},{id:1,desc:1,label:1,LocationTree:1,path:1,coordinates:1,_id: 0}).toArray();
return result;
【问题讨论】:
当我第一次开始使用 Stitch 时,我就这个问题联系了 MongoDB 支持。他们指出没有办法抑制返回的类型 numeric 和 datetime 值类型。
您的客户端应用程序必须在处理 JSON 响应时处理类型。这是用点表示法完成的。
假设您的 id 字段的类型为 Int32。
典型的 API 调用可能会在 result.id 处返回整数或字符串。但是,Stitch HTTP 服务会将类型附加到值,并在 result.id.$numberInt 处返回它。
如上所述,类型数据包含在 numeric 和 datetime 值中。布尔值、字符串、对象和数组不包括类型数据。可以通过result.someBoolean、result.someString、result.someObject 或result.someArray 访问它们。
我还没有找到 Stitch HTTP 服务返回的类型的完整列表。出于某种原因,它们与BSON Type aliases 不匹配。
【讨论】: