Add mapping to lists of objects
See original GitHub issueWhile 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?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to add the map objects to the List in java - Stack Overflow
To create a list: List<Map<Object, Object> myList = new ArrayList<>();. Then use myList.add(map) to add maps to this list.
Read more >How To Use .map() to Iterate Through Array Items in JavaScript
One of the most popular methods is the .map() method. .map() creates an array from calling a specific function on each item in...
Read more >Mapping Lists with ModelMapper - Baeldung
In this tutorial, we explained how lists are mapped by manipulating generic types in ModelMapper. We can make use of TypeToken, generic type ......
Read more >Build Maps Marker Layer with Related Lists - Salesforce Help
Check out the video below for steps to add related list to a Maps Marker Layer in Salesforce Maps ... Choose a Related...
Read more >Array.prototype.map() - JavaScript - MDN Web Docs
The map() method creates a new array populated with the results of calling a provided function on every element in the calling array....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 notifications@github.com wrote:
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