Skip to content

Commit 2ca5dc9

Browse files
committed
2 parents d194413 + ac8e5c3 commit 2ca5dc9

File tree

1 file changed

+56
-8
lines changed

1 file changed

+56
-8
lines changed

README.md

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Automatically create tables based on the model. To achieve additions and deletio
88

99
#### Use
1010

11-
实现协议方法.
12-
Imp <SJDBMapUseProtocol> Method.
11+
实现协议方法.
12+
Imp SJDBMapUseProtocol Method.
1313

1414
```
1515
@interface SampleVideoModel : NSObject<SJDBMapUseProtocol>
@@ -42,10 +42,10 @@ Imp <SJDBMapUseProtocol> Method.
4242
```
4343

4444
#### insertOrUpdate 插入数据或更新数据
45+
数据在插入表之前, 会检测是否已经存在相关表。如果不存在,会先创建相关表(可能会创建多个表), 再进行数据的更新或插入。
46+
如果类中新添了属性, 会自动检测并更新相关表字段。
4547
Data before the table is inserted, it will detect whether the relevant table already exists. If it does not exist, it will first create a related table (may create multiple tables), and then update the data or insert.
4648
If a new attribute is added to the class, the associated table field is automatically detected and updated.
47-
数据在插入表之前, 会检测是否已经存在相关表。如果不存在,会先创建相关表(可能会创建多个表), 再进行数据的更新或插入。
48-
如果类中新添了属性, 会自动检测并更新相关表字段。
4949

5050
```
5151
- (void)insertOrUpdate {
@@ -63,30 +63,78 @@ If a new attribute is added to the class, the associated table field is automati
6363
// ....
6464
}];
6565
}
66+
- (void)update {
67+
[[SJDatabaseMap sharedServer] update:person property:@[@"tags", @"age"] callBlock:^(BOOL result) {
68+
// ....
69+
}];
70+
71+
[[SJDatabaseMap sharedServer] update:person insertedOrUpdatedValues:@{@"tags":insertedValues} callBlock:^(BOOL r) {
72+
// ....
73+
}];
74+
}
6675
```
6776
#### delete 删除
77+
删除数据是删除该类对应的表的数据, 与其关联的其他类的数据没有做处理。
6878
Deleting data is to delete the data of the corresponding table of the class, and the data of the other class associated with it is not processed.
69-
删除数据是删除该类对应的表的数据, 与其关联的其他类的数据没有做处理。
7079

7180
```
7281
- (void)del {
7382
[[SJDBMap sharedServer] deleteDataWithClass:[Person class] primaryValue:0 callBlock:^(BOOL result) {
7483
// ...
7584
}];
85+
[[SJDatabaseMap sharedServer] deleteDataWithClass:[Person class] primaryValues:@[@(1), @(0)] callBlock:^(BOOL r) {
86+
// ...
87+
}];
88+
[[SJDatabaseMap sharedServer] deleteDataWithModels:personModels callBlock:^(BOOL result) {
89+
// ...
90+
}];
7691
}
7792
```
7893
#### query 查询
94+
查询数据会将与该类相关的所有数据都读取出来, 并转换相应的模型。
7995
The query data will read all the data associated with that class and convert the corresponding model.
80-
查询数据会将与该类相关的所有数据都读取出来, 并转换相应的模型。
8196

8297
```
8398
- (void)query {
8499
[[SJDBMap sharedServer] queryAllDataWithClass:[Person class] completeCallBlock:^(NSArray<id> * _Nonnull data) {
85100
// ...
86101
}];
102+
103+
[[SJDatabaseMap sharedServer] queryDataWithClass:[Person class] primaryValue:12 completeCallBlock:^(id<SJDBMapUseProtocol> _Nullable model) {
104+
// ...
105+
}];
106+
107+
[[SJDatabaseMap sharedServer] queryDataWithClass:[Person class] queryDict:@{@"name":@"sj", @"age":@(20)} completeCallBlock:^(NSArray<id<SJDBMapUseProtocol>> * _Nullable data) {
108+
// ...
109+
}];
110+
111+
[[SJDatabaseMap sharedServer] queryDataWithClass:[Person class] range:NSMakeRange(2, 10) completeCallBlock:^(NSArray<id<SJDBMapUseProtocol>> * _Nullable data) {
112+
// ...
113+
}];
114+
}
115+
// 模糊查询
116+
- (void)fuzzyQuery {
117+
// 匹配以 's' 开头的name.
118+
[[SJDatabaseMap sharedServer] fuzzyQueryDataWithClass:[Person class] queryDict:@{@"name":@"s"} match:SJDatabaseMapFuzzyMatchFront completeCallBlock:^(NSArray<id<SJDBMapUseProtocol>> * _Nullable data) {
119+
// ...
120+
}];
121+
* 匹配左右两边
122+
* ...A...
123+
*/
124+
SJDatabaseMapFuzzyMatchAll = 0,
125+
/*!
126+
* 匹配以什么开头
127+
* ABC.....
128+
*/
129+
SJDatabaseMapFuzzyMatchFront,
130+
/*!
131+
* 匹配以什么结尾
132+
* ...DEF
133+
*/
134+
SJDatabaseMapFuzzyMatchLater
87135
}
88136
```
89137
#### Use attention 使用注意
90-
138+
模型需要一个主键或自增主键  
91139
The model requires a primary key or a self-incrementing key
92-
模型需要一个主键或自增主键
140+

0 commit comments

Comments
 (0)