我坚持使用 moor 使用变量的自定义查询。使用时不返回列表
SELECT * FROM books WHERE title LIKE searchString;
。我错过了什么吗?
代码:
Stream<List<Book>> getFilteredBook(String searchString) {
searchString = 'the';
return customSelect(
//query works fine
//'SELECT * FROM books;',
'SELECT * FROM books WHERE title LIKE searchString;',
variables: [
Variable.withString(searchString),
],
readsFrom: {books},
).watch().map((rows) {
// Turning the data of a row into a Book object
return rows.map((row) => Book.fromData(row.data)).toList();
});
}