无
- 发布:2024-01-14 11:39
- 更新:2024-01-14 11:53
- 阅读:266
产品分类: uniCloud/App
操作步骤:
预期结果:
nearTargets: [
{
target_id:"{
_id:"xxx",
xx:"xxx"
},
distance:10,
difficulty:20
},
{
target_id:{
_id:"xxx",
xx:"xxx"
},
distance:10,,
difficulty:20
}
]
nearTargets: [
{
target_id:"{
_id:"xxx",
xx:"xxx"
},
distance:10,
difficulty:20
},
{
target_id:{
_id:"xxx",
xx:"xxx"
},
distance:10,,
difficulty:20
}
]
实际结果:
nearTargets: {
target_id:[]
}
nearTargets: {
target_id:[]
}
bug描述:
主表内的字段类型为数组,数组元素类型为object,object内元素关联副表_id字段。
主表内此字段定义如下:
"nearTargets":{
"bsonType": "array",
"arrayType": "object",
"required": [
"target_id","distance"
],
"permission":{
"write":false
},
"properties": {
"target_id": {
"bsonType": "string",
"foreignKey": "pms-target-list._id"
},
"distance": {
"bsonType": "int",
},
"difficulty": {
"bsonType": "int",
}
}
},
查询代码
let mkTemp = db.collection('主表名’).where("_id=='"+id+"'")
.getTemp()
db.collection(mkTemp, 'pms-target-list')
.get()
.then((res) => {
console.log(res);
结果内此字段格式和数据如下:
nearTargets: {
target_id:[]
}
结果格式错误,nearTargets应该是一个数组,每个元素应该为一个对象。而且结果数据为空,但实际表里有数据。
y***@sina.com (作者)
bsonType是Object,Object里面有关联字段,这种是没有问题的。这种数组内是object应该也要支持呀。而且如果不支持,那也应该报错,不应该返回错误的结果。
2024-01-14 12:02