首先,我首先定义了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.
您可以检查一下. github/realm/realm -js/blob/master/examples/ReactExample/components/realm.js
Hoho,我们可以在任何需要的地方调用领域db.
Hoho, we can call the realm db anywhere we want.
更多推荐
在架构中找不到对象类型xxx
发布评论