Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/418.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将Realm与React Native一起使用?_Javascript_Ios_React Native_Realm - Fatal编程技术网

Javascript 如何将Realm与React Native一起使用?

Javascript 如何将Realm与React Native一起使用?,javascript,ios,react-native,realm,Javascript,Ios,React Native,Realm,我曾尝试在我的项目中使用领域,但收效甚微,我对此感到迷茫 我遵循了本教程:没有运气,还有官方文档: 定义一个领域并写入它似乎是可行的,但我无法从中读取数据 我创建数据库的代码: const userSchema = { name:'User', properties:{ name:'string', phone:'string', loggedIn:{type:'bool', default:false} } }; const realm = new Realm({sch

我曾尝试在我的项目中使用领域,但收效甚微,我对此感到迷茫

我遵循了本教程:没有运气,还有官方文档:

定义一个领域并写入它似乎是可行的,但我无法从中读取数据

我创建数据库的代码:

const userSchema = {
name:'User',
properties:{
    name:'string',
    phone:'string',
    loggedIn:{type:'bool', default:false}
}
};
const realm = new Realm({schema: [userSchema]});
下面是阅读功能:

export function getUsers(){
Realm.open({schema: [userSchema]})
.then(realm => {
        const users = realm.objects('User');
        return users;
});
}

下面是一些问题:

  • 在getUsers函数中,realm.objects不返回任何结果,而是:

    代理{-1:未定义,符号(领域):10,符号(id):14,符号(类型):“结果”,…} [[Handler]]:对象 [[Target]]:结果 [[isr]]:false

  • 我怎样才能得到实际的结果呢

  • 每次对数据库执行任何操作时都必须使用
    Realm.open()

  • 有人能举一个创建领域数据库、写入数据和获取数据的代码和文件的例子吗


  • 非常感谢您提供的任何帮助。

    可能重复的返回
    Promise.resolve()
    然后您可以通过
    then()
    @EpicPandaForce看到它,谢谢!成功了。返回的可能重复
    Promise.resolve()
    ,然后您可以通过
    then()
    @EpicPandaForce看到它,谢谢!成功了。