react-native - 无法在我的领域数据库中检索项目数组
问题描述
我正在尝试从Item
从我的本地数据库调用的表中检索一个数组,该表有我创建的大约 42 条记录,以便稍后查询和测试。但是,当我在按钮按下功能上请求数据时,我想看看数据是什么样子的。波纹管是我的组件:
const TestIndex = () => {
const config = {
schema: [ItemSchema],
};
const realm = new Realm(config);
const onSaveItem = async () => {
const items = await realm.objects("Item");
return console.log(items);
};
return <Button buttonText="Save" buttonPress={onSaveItem} />;
}
我的架构如下:
export const ItemSchema = {
name: "Item",
properties: {
_id: "objectId",
itemCode: "string",
itemDescription: "string",
itemPrice: "string",
partition: "string",
},
primaryKey: "_id",
};
当我运行该函数时,我期待一个包含我的数据的对象数组,但是当我得到这个时console.log(items)
:
Proxy {isRealmCtor: true}
[[Handler]]: Object
get: ƒ ()
arguments: null
caller: null
length: 0
name: ""
prototype: {constructor: ƒ}
__proto__: ƒ ()
[[Scopes]]: Scopes[0]
getOwnPropertyDescriptor: ƒ ()
getPrototypeOf: ƒ ()
has: ƒ ()
ownKeys: ƒ ()
set: ƒ ()
setPrototypeOf: ƒ ()
__proto__: Object
[[Target]]: Results
[[IsRevoked]]: false
解决方案
推荐阅读
- nsdecimalnumber - NSDecimalNumber 使用库存 NumberFormatter 丢失精度
- asp.net - .Net Core API 与 ReactJS 应用程序。错误翻译应该存储在哪里?
- sql - 在 Hive 中将复杂数据类型与 NULL 合并
- yocto - bitbake 第二次成功构建,而不是第一次使用 devtool
- javascript - 取消输入类型=“文件”上的事件隐藏
- java - kafka JDBC源连接器无法获取postgress表
- excel - 查找 Excel 加载项的快捷方式
- redux - 使用 MSW 和 Jest 时如何在请求之间的测试中清除 RTK 查询缓存?
- python - 有人可以用 Python 解释这种行为吗?
- laravel - 如何在 JavaScript 中设置 url 以将多个参数传递给 Laravel 中的控制器而不使用请求