我们的本机(0.62.0)和领域(5.0.2)部署存在以下问题:
我们有一个包含几个模型的模式,其中一个是Location
。我们可以在两种设备(ios和android)上都插入位置,但是,当我们想从中检索对象时,它只能在ios上工作。
{
name: 'Location',
primaryKey: 'uuid',
properties: {
uuid: {type: 'string', indexed: true},
id: {type: 'int'},
title: 'string?',
latitude: 'float?',
longitude: 'float?',
latitudedelta: 'float?',
longitudedelta: 'float?',
radius: 'float?',
},
},
我们执行以下操作以访问我们的领域:
let repository = new Realm({schema:[{
name: 'Location',..see above..}]});
export const LocationService = {
findAll: function(sortBy) {
let results = repository.objects('Location');
console.log('LocationService.findAll', results);
return results;
},
};
使用iOS时,我们具有以下console.log:
LocationService.findAll {"0": {"id": 11, "latitude": 53.160179138183594, "latitudedelta": 0, "longitude": 10.146489143371582, "longitudedelta": 0.08983111381530762, "radius": 35, "title": "", "uuid": "16e1b034-f4b9-44d8-9f58-e30de82dd346"}, "1": {"id": 1, "latitude": 40.732025146484375, "latitudedelta": 0, "longitude": -74.00248718261719, "longitudedelta": 0.08983111381530762, "radius": 35, "title": "", "uuid": "ada51419-eea0-45ef-8209-581ce083a4fc"}, "2": {"id": 2, "latitude": 51.5080680847168, "latitudedelta": 0.2786773443222046, "longitude": -0.13921460509300232, "longitudedelta": 0.08983111381530762, "radius": 35, "title": "", "uuid": "4311470f-d790-4c40-a2b1-f210b723fa08"}, "3": {"id": 12, "latitude": 53.76025390625, "latitudedelta": 0, "longitude": 9.679306983947754, "longitudedelta": 0.08983111381530762, "radius": 35, "title": "", "uuid": "82b40618-051d-49b3-9281-334796e5660c"}}
与Android一样,我们获得以下console.log:
LocationService.findAll {"0": {}}
后面的代码中,我们强制访问了ID,例如:
let loadedLocations = LocationService.findAll();
loadedLocations.forEach(l => {
console.log(l.id);
});
同样,在iOS上,我们会获得带有ID的console.log输出,而在android上,我们只会看到未定义的内容。
在实际设备上连接调试器并在控制台中对其进行检查时,我们还可以在结果输出中看到更多信息:
有趣的是,在架构中的其他模型上,我们在Android上没有此问题。 Android会完美加载其他模型。在确定位置的情况下,它确实看到了领域实例中的一个条目,并且当我们从设备(仿真器和真实测试设备)下载.realm文件时,我们可以看到条目是正确制作的!
可能是个问题,仅在此模型上,仅在获取对象上,仅在android上,我们才遇到此问题?
答案 0 :(得分:1)
将领域更新到版本5.0.3
领域js 5.0.2 https://github.com/realm/realm-js/releases/tag/v5.0.3