【发布时间】:2021-08-05 07:13:16
【问题描述】:
我正在使用 React-native 的 Javascript 领域
我想生成一个领域模式来保存一个 Object 数组,如下所示:
arrayOfObj:[{ key1:1111, key2:2222, key3:333 }]
到目前为止,我尝试的是在我的架构中使用 mixed 类型
const mySchema = {
name: "mySchema",
properties: {
_id: "objectId",
arrOfObj: "mixed" //'have used mixed[] too but they all don't work
}
}
我尝试过使用 mixed 和 mixed[] 但是当我尝试插入对象数组时出现错误:mySchema.arrOfObj must be of type 'mixed?[]', got 'object' ([object Object])].
现在,领域中对象数组的正确数据类型是什么?
【问题讨论】:
-
你想在数组中存储任何数据还是你知道数据的结构?
-
@MichaelBahl 我想将 一个对象存储在一个数组中,其键值对为 ObjectId: Integer,类似于
[ {'60b6c1381d5d2f2afe4b3b' : 2, '51b6c15a1d7d6a2ba99a6c' : 3} ] -
@MichaelBahl 你能提供一些帮助吗?
标签: react-native realm mongodb-realm