While using this library I constantly find myself repeating this over and over again:
Cursor cursor = dbHelper.getReadableDatabase()
.rawQuery(SomeModel.SELECT_SOMETHING);
List<SomeModel> models = new ArrayList<>(cursor.getCount());
while (cursor.moveToNext()) {
models.add(SomeModel.MAPPER.map(cursor));
}
cursor.close();
return models;
Do you plan on introducing something like LIST_MAPPER.map(cursor) or any utility function which would do the same?
Of course, I could introduce my own helper in my codebase, but I thought it might be such a common pattern that library might have it too. Or do I miss something here?
We use SQL Brite for using SQL Delight-generated mappers at runtime. It has
the convenience method you describe for mapping Cursor into List.
We can probably offer a bit more in SQL Delight for using it by itself, but
it's not our main focus.
On Mon, Jun 13, 2016 at 6:40 AM dimsuz [email protected] wrote:
While using this library I constantly find myself repeating this over and
over again:Cursor cursor = dbHelper.getReadableDatabase() .rawQuery(SomeModel.SELECT_SOMETHING); List<SomeModel> models = new ArrayList<>(cursor.getCount()); while (cursor.moveToNext()) { models.add(SomeModel.MAPPER.map(cursor)); } cursor.close(); return models;Do you plan on introducing something like LIST_MAPPER.map(cursor) or any
utility function which would do the same?
Of course, I could introduce my own helper in my codebase, but I thought
it might be such a common pattern that library might have it too. Or do I
miss something here?—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/square/sqldelight/issues/327, or mute the thread
https://github.com/notifications/unsubscribe/AAEEEdRKG6SQBVef8pIMnJjgBWg9fbODks5qLTOpgaJpZM4I0M3m
.
I see. Will look into SQL Brite a bit more, haven't made use of it as of now.
What's that convenience method in SQLBrite? I use the two of these libraries together and ended up writing my own util method. Didn't realize one was built-in.
QueryObservable.mapToList (or Query.mapToList). We use it with
Retrolambda/Jack so that you can use a method reference:
db.createQuery(..)
.mapToList(User.MAPPER::map)
.subscribe(..)
On Mon, Jun 13, 2016 at 11:06 AM Kevin Most [email protected]
wrote:
What's that convenience method in SQLBrite? I use the two of these
libraries together and ended up writing my own util method. Didn't realize
one was built-in.—
You are receiving this because you commented.Reply to this email directly, view it on GitHub
https://github.com/square/sqldelight/issues/327#issuecomment-225609472,
or mute the thread
https://github.com/notifications/unsubscribe/AAEEEYTPCKdk4npJGQmDigs58_oNDs9gks5qLXH-gaJpZM4I0M3m
.
I'm gonna close this for now. In the future we'll probably have tighter links between SQLDelight and SQLBrite but at least for we'll keep functionality separate between them
Most helpful comment
QueryObservable.mapToList (or Query.mapToList). We use it with
Retrolambda/Jack so that you can use a method reference:
db.createQuery(..)
.mapToList(User.MAPPER::map)
.subscribe(..)
On Mon, Jun 13, 2016 at 11:06 AM Kevin Most [email protected]
wrote: