mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-06 16:48:24 +08:00
update docs
This commit is contained in:
parent
d15fdf98e8
commit
877d3b8058
@ -67,14 +67,14 @@ public class HelloWorld {
|
|||||||
.addMapper(AccountMapper.class)
|
.addMapper(AccountMapper.class)
|
||||||
.start();
|
.start();
|
||||||
|
|
||||||
|
//获取 mapper
|
||||||
|
AccountMapper mapper = MybatisFlexBootstrap.getInstance()
|
||||||
|
.getMapper(AccountMapper.class);
|
||||||
|
|
||||||
//示例1:查询 id=1 条数据
|
//示例1:查询 id=1 的数据
|
||||||
Account account = MybatisFlexBootstrap.getInstance()
|
Account account = mapper.selectOneById(1);
|
||||||
.execute(AccountMapper.class, mapper ->
|
|
||||||
mapper.selectOneById(1)
|
|
||||||
);
|
|
||||||
|
|
||||||
//示例2:或者使用 Db + Row 查询
|
//示例2:者使用 Db + Row 查询
|
||||||
String sql = "select * from tb_account where age > ?";
|
String sql = "select * from tb_account where age > ?";
|
||||||
List<Row> rows = Db.selectListBySql(sql, 18);
|
List<Row> rows = Db.selectListBySql(sql, 18);
|
||||||
}
|
}
|
||||||
|
|||||||
18
readme.md
18
readme.md
@ -57,12 +57,12 @@ class HelloWorld {
|
|||||||
.addMapper(AccountMapper.class)
|
.addMapper(AccountMapper.class)
|
||||||
.start();
|
.start();
|
||||||
|
|
||||||
|
AccountMapper mapper = MybatisFlexBootstrap.getInstance()
|
||||||
|
.getMapper(AccountMapper.class);
|
||||||
|
|
||||||
|
|
||||||
//id=100
|
//id=100
|
||||||
Account account = MybatisFlexBootstrap.getInstance()
|
Account account = mapper.selectOneById(100);
|
||||||
.execute(AccountMapper.class, mapper ->
|
|
||||||
mapper.selectOneById(100)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -81,10 +81,7 @@ QueryWrapper query = QueryWrapper.create()
|
|||||||
// ELECT * FROM tb_account
|
// ELECT * FROM tb_account
|
||||||
// WHERE tb_account.id >= 100
|
// WHERE tb_account.id >= 100
|
||||||
// AND (tb_account.user_name LIKE '%zhang%' OR tb_account.user_name LIKE '%li%' )
|
// AND (tb_account.user_name LIKE '%zhang%' OR tb_account.user_name LIKE '%li%' )
|
||||||
List<Account> accounts = MybatisFlexBootstrap.getInstance()
|
List<Account> accounts = mapper.selectListByQuery(query);
|
||||||
.execute(AccountMapper.class, mapper ->
|
|
||||||
mapper.selectListByQuery(query)
|
|
||||||
);
|
|
||||||
```
|
```
|
||||||
|
|
||||||
e.g.3: paging query
|
e.g.3: paging query
|
||||||
@ -104,10 +101,7 @@ QueryWrapper query = QueryWrapper.create()
|
|||||||
// AND (tb_account.user_name LIKE '%zhang%' OR tb_account.user_name LIKE '%li%' )
|
// AND (tb_account.user_name LIKE '%zhang%' OR tb_account.user_name LIKE '%li%' )
|
||||||
// ORDER BY tb_account.id DESC
|
// ORDER BY tb_account.id DESC
|
||||||
// LIMIT 40,10
|
// LIMIT 40,10
|
||||||
Page<Account> accountPage = MybatisFlexBootstrap.getInstance()
|
Page<Account> accountPage = mapper.paginate(5, 10, query);
|
||||||
.execute(AccountMapper.class, mapper ->
|
|
||||||
mapper.paginate(5, 10, query)
|
|
||||||
);
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## QueryWrapper Samples
|
## QueryWrapper Samples
|
||||||
|
|||||||
18
readme_zh.md
18
readme_zh.md
@ -70,12 +70,12 @@ class HelloWorld {
|
|||||||
.addMapper(AccountMapper.class)
|
.addMapper(AccountMapper.class)
|
||||||
.start();
|
.start();
|
||||||
|
|
||||||
|
AccountMapper mapper = MybatisFlexBootstrap.getInstance()
|
||||||
|
.getMapper(AccountMapper.class);
|
||||||
|
|
||||||
|
|
||||||
//示例1:查询 id=100 条数据
|
//示例1:查询 id=100 条数据
|
||||||
Account account = MybatisFlexBootstrap.getInstance()
|
Account account = mapper.selectOneById(100);
|
||||||
.execute(AccountMapper.class, mapper ->
|
|
||||||
mapper.selectOneById(100)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -96,10 +96,7 @@ QueryWrapper query=QueryWrapper.create()
|
|||||||
// ELECT * FROM tb_account
|
// ELECT * FROM tb_account
|
||||||
// WHERE tb_account.id >= 100
|
// WHERE tb_account.id >= 100
|
||||||
// AND (tb_account.user_name LIKE '%张%' OR tb_account.user_name LIKE '%李%' )
|
// AND (tb_account.user_name LIKE '%张%' OR tb_account.user_name LIKE '%李%' )
|
||||||
List<Account> accounts = MybatisFlexBootstrap.getInstance()
|
List<Account> accounts = mapper.selectListByQuery(query);
|
||||||
.execute(AccountMapper.class,mapper->
|
|
||||||
mapper.selectListByQuery(query)
|
|
||||||
);
|
|
||||||
```
|
```
|
||||||
|
|
||||||
示例3:分页查询
|
示例3:分页查询
|
||||||
@ -120,10 +117,7 @@ QueryWrapper query=QueryWrapper.create()
|
|||||||
// AND (user_name LIKE '%张%' OR user_name LIKE '%李%' )
|
// AND (user_name LIKE '%张%' OR user_name LIKE '%李%' )
|
||||||
// ORDER BY `id` DESC
|
// ORDER BY `id` DESC
|
||||||
// LIMIT 40,10
|
// LIMIT 40,10
|
||||||
Page<Account> accounts = MybatisFlexBootstrap.getInstance()
|
Page<Account> accounts = mapper.paginate(5,10,query);
|
||||||
.execute(AccountMapper.class,mapper->
|
|
||||||
mapper.paginate(5,10,query)
|
|
||||||
);
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## QueryWrapper 示例
|
## QueryWrapper 示例
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user