I need update and if not exist insert row to ROOM DB.
I make this: productRepository.updateProducts(productsResponse.getProductItems());
And:
@Override
public void updateProducts(final List<ProductItem> products) {
new Thread(() -> {
for (ProductItem item : products) {
Product product = createProduct(item);
productDao.insert(product);
}
}).start();
}
And in DAO:
@Insert
void insert(Product products);
But I have method
@Update
void update(Product product);
And I have some questions:
both methods is void. How can I return saved Product or boolean flag or inserted count after insert?
if I try call
update
and I have not row will it be inserted?How can I update(if not - insert) row and return count updatet or inserted rows?