在架构中找不到对象类型xxx [英] Object Type xxx is not found in schema

查看:112
本文介绍了在架构中找不到对象类型xxx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我首先定义了TestSchema,并创建了"let realm = new Realm({schema:[TestSchema]})",并且{realm.objects('Test').length}的结果正确. 当我尝试向领域中添加更多架构时,例如'let realm = new Realm({schema:[TestSchema,CarSchema,PersonSchema]})'',它显示了错误的味精. 在架构中找不到对象类型的汽车".我想知道这里发生了什么.

Firstly, i defined the TestSchema first, and create "let realm = new Realm({schema: [TestSchema]})",and the result for {realm.objects('Test').length} is right. When i try to add more schemas into realm, e.g.'let realm = new Realm({schema:[TestSchema, CarSchema, PersonSchema]})', it shows the wrong msg. "Object Type Car is not found in schema". I was wondering what's going on here.

推荐答案

将所有这些架构定义放在一个文件中,例如realm.js,并导出这些架构.

Put all these schema definitions in one file, say realm.js, and export these schemas.

您可以检查一下. https://github.com/realm/realm -js/blob/master/examples/ReactExample/components/realm.js

Hoho,我们可以在任何需要的地方调用领域db.

Hoho, we can call the realm db anywhere we want.

这篇关于在架构中找不到对象类型xxx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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