轻量级数据库引擎(替代SQLite,高性能本地数据管理)
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 5 个月前 | ||
| 5 个月前 | ||
| 5 个月前 | ||
| 5 个月前 | ||
| 5 个月前 | ||
| 5 个月前 | ||
| 1 个月前 | ||
| 5 个月前 | ||
| 4 年前 | ||
| 5 个月前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 5 年前 | ||
| 5 个月前 |
isar
本项目基于 isar 开发。
1. 安装与使用
1.1 安装方式
进入到工程目录并在 pubspec.yaml 中添加以下依赖:
pubspec.yaml
dependencies:
isar:
git:
url: "https://gitcode.com/CPF-Flutter/fluttertpc_isar"
path: packages/isar_flutter_libs
# ref: 3.1.0_1-ohos-1.0.0
ref: x.x.x-ohos-x.x.x-beta.x # 请根据下方TAG版本对应表选择TAG
执行命令
flutter pub get
TAG 版本对应表
| Flutter 框架版本 | TAG | 分支 |
|---|---|---|
| 3.7 | - | - |
| 3.22 | 3.1.0_1-ohos-1.0.0 | br_3.22 |
| 3.27 | - | - |
| 3.35 | - | - |
1.2 使用案例
使用案例详见 example
2. 约束与限制
2.1 兼容性
在以下版本中已测试通过
- Flutter: 3.22.0-ohos-1.0.4; SDK: 5.1.1(19); IDE: DevEco Studio: 5.1.1.830; ROM: 5.1.0.150 SP3;
2.2 权限要求
2.2.1在 entry 目录下的module.json5中添加权限
打开 entry/src/main/module.json5,添加:
"requestPermissions": [
{"name" : "ohos.permission.INTERNET"},
{
"name": "ohos.permission.READ_MEDIA",
"reason": "$string:read",
"usedScene": {
"abilities": [
"EntryAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.WRITE_MEDIA",
"reason": "$string:write",
"usedScene": {
"abilities": [
"EntryAbility"
],
"when": "inuse"
}
},
]
3. API
"ohos Support"列为 yes 表示 ohos 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
| Name | Description | Type | Input | Ouput | ohos Support |
|---|---|---|---|---|---|
| Isar.open | 打开数据库实例 | function | List<CollectionSchema<dynamic>> schemas, { required String directory, String name, int maxSizeMiB, bool relaxedDurability, CompactCondition? compactOnLaunch, bool inspector} |
Future<Isar> | yes |
| Isar.writeTxn | 写/读事务 | function | Future<T> Function() callback, {bool silent} |
Future<T> | yes |
| IsarCollection.get | 查询对象 | function | Id id | Future<OBJ?> | yes |
| IsarCollection.put | 插入/更新对象 | function | OBJ object | Future<Id> | yes |
| IsarCollection.delete | 删除对象 | function | Id id | Future<bool> | yes |
| IsarCollection.buildQuery | 手动构建自定义查询 | function | {List<WhereClause> whereClauses, bool whereDistinct, Sort whereSort, FilterOperation? filter, List<SortProperty> sortBy, List<DistinctProperty> distinctBy, int? offset, int? limit, String? property} |
Query<R> | yes |
| QueryBuilder.filter | 过滤 | function | FilterQuery<OBJ> filter | QueryBuilder<OBJ, OBJ, QAfterFilterCondition> | yes |
| QueryBuilder.sortBy | 排序 | function | String propertyName, Sort sort | QueryBuilderInternal<OBJ> | yes |
| QueryBuilder.limit | 限制 | function | int? limit | QueryBuilderInternal<OBJ> | yes |
| Query.findAll | 查询所有结果 | function | / | Future<List<T>> | yes |
| Query.deleteAll | 批量删除 | function | / | Future<int> | yes |
4. 遗留问题
5. 开源协议
本项目基于 Apache License 2.0,请自由地享受和参与开源。