How to store [String] or [Int] in react-native realm

青春壹個敷衍的年華 提交于 2019-12-04 14:12:46

You can use the same strategy in react-native:

var intObject = {
  name: 'intObject',
  properties: { value: 'int' }
};

var intListObject = {
  name: 'intListObject',
  properties: { 
    'intList': { type: 'list', objectType: 'intObject' } }
};

var realm = new Realm({schema: [intObject, intListObject]});

var listObject = realm.create('intListObject', { 
  intList: [{value: 0}, {value: 2}, ...]
});

var value = listObject.intList[1].value; // 2

We plan to support arrays of primitive types without the extra abstraction but there isn't yet an eta for this feature.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!