harmony-database/README.md
2023-10-08 17:49:17 +08:00

21 lines
518 B
Markdown

# Template
## database
注意事项
1. 由于`constructor()`函数不能异步,因此在其中调用`getRdbStore()`
函数时,不能保证新建对象后,数据库初始化完毕。那么此时如果调用`insert`等方法时,`RdbStore`可能还是`undefined`,导致数据库操作失败。
因此,只能使用回调来处理。
```typescript
aboutToAppear() {
this.todoTable.getRdbStore(async () => {
const res = await this.todoTable.query();
this.todoList = res;
})
}
```