turbomanage / storm-gen

Simple ORM for Android SQLite
Apache License 2.0
83 stars 15 forks source link

Need insertOrUpdate() method #35

Closed Gopinathp closed 9 years ago

Gopinathp commented 9 years ago

Many times, we end up doing the below if we are syncing data between the cloud and the mobile device.

try { dao.insertMany(list); } catch(Exception e) { for(Item i: list) { try { dao.insert(i); } catch(Exception e) { dao.update(i); } }

Please provide a method like dao.saveAll(list) or dao.save(item)

turbomanage commented 9 years ago

I could provide a save(item) method which selects between insert / update based on the ID (if 0, insert, else update). Would that behavior work for you? A saveAll() method, unfortunately, would lose the efficiency of insertMany() because it could not use a single prepared statement, so I don't think there is as much value in that but I'm not opposed to adding it.

xanscale commented 9 years ago

save(item) for me +1 saveAll() for me -1