如何在react-native域中存储[String]或[Int] [英] How to store [String] or [Int] in react-native realm

查看:334
本文介绍了如何在react-native域中存储[String]或[Int]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在线阅读在Android / iOS中我应该从RealmObject继承并创建我自己的RealmString以用作列表中的objectType。

I've read online where in Android/iOS I should inherit from RealmObject and create my own RealmString to use as my objectType in a list.

这是什么方法反应原生?我找不到任何关于如何处理这个问题的代码示例。

What's the approach in react-native? I can't find any code samples on how to handle this issue.

谢谢

推荐答案

您可以在react-native中使用相同的策略:

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

我们计划在没有额外抽象的情况下支持原始类型的数组但是还没有这个功能的eta。

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

这篇关于如何在react-native域中存储[String]或[Int]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆