pho*_*ong 1 sqlite dart flutter sqflite
我如何使用 sqflite 并且只在 flutter 上查询 1 行数据。
Future<dynamic> queryOneDaily (int id, String date) async {
final db = await database;
return await db.query(
Constants.dbTable,
where: "${Constants.dbColId} = ? AND ${Constants.dbColDate} = ?",
whereArgs: [id, date],
);
}
Run Code Online (Sandbox Code Playgroud)
来自 sqlite https://github.com/tekartik/sqflite/blob/master/sqflite/lib/sqlite_api.dart 的源代码
您可以使用 limit
代码片段
Future<dynamic> queryOneDaily (int id, String date) async {
final db = await database;
return await db.query(
Constants.dbTable,
where: "${Constants.dbColId} = ? AND ${Constants.dbColDate} = ?",
whereArgs: [id, date],
limit: 1
);
}
Run Code Online (Sandbox Code Playgroud)
源代码的代码片段
/// @param limit Limits the number of rows returned by the query,
Future<List<Map<String, dynamic>>> query(String table,
{bool distinct,
List<String> columns,
String where,
List<dynamic> whereArgs,
String groupBy,
String having,
String orderBy,
int limit,
int offset});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3869 次 |
| 最近记录: |