Realm JS使用原始数据类型列表

时间:2016-08-01 14:01:26

标签: reactjs realm realm-list

我无法创建仅包含字符串对象的列表

这就是我的模型的样子

class ProductSummary extends Realm.Object {}
ProductSummary.schema = {
name: 'ProductSummary',
properties: {
productId:'string',
name:'string',
description:'string',
rating:'int',
comments:'int',
categories:{type:'list',objectType:'string'},
images:{type:'list',objectType:'string'},
price:{type:'Price'}
 }
};

这是我从api得到的回复

"productSummary": { "links": [], "productId": "PRD_1ola611nd0t", "name": "Sample", "description": "<p>Sample<br></p>", "categories": [ "CAT_1rua60fnd0u" ], "rating": 0, "comments": 0, "tags": [], "image": "http://test.testsite.com/testProject/app-images/189_66164247/189_42527954.jpeg", "price": { "lowest": 100, "highest": 100 } }

我收到以下错误

Target Type 'string' doesn't Exists for property 'categories'

我是否以错误的方式创建了“类别”字段。

1 个答案:

答案 0 :(得分:0)

这是针对本机的域js的​​限制,解决方法是在执行db事务之前将字符串列表包装为对象列表(作为键值对),更多信息和问题的状态被跟踪在此github issue