Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 29428

React-Native Realm on Android returns empty objects, works fine on iOS

$
0
0

We have the following issue with our react-native (0.62.0) and realm (5.0.2)deployment:

We have a schema with a few models, one of which is Location. We can insert into location on both devices (ios and android) however, when we want to retrieve objects from it, it only works on 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?',      },    },

We do the following to access our realm:

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;  },};

When using iOS we have the following 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"}}

Where as on Android we get the following console.log:

LocationService.findAll {"0": {}}

Later on in the code we have force access the id for instance:

let loadedLocations = LocationService.findAll();    loadedLocations.forEach(l => {      console.log(l.id);    });

Again, on iOS we get the console.log outputs with the ID, whereas on android we only see undefined.

Interestingly, on our other models in the schema we do not have this problem on Android. The android loads perfectly the other models. In the location case it does see, that there is one entry in the realm instance, and when we download the .realm file from the device (emulator && real testing device) we can see that the entries are correctly made!

What could be the problem, that only on this model, only on fetching the objects and only on android we run into this problem?


Viewing all articles
Browse latest Browse all 29428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>