I want to update multiple record (DBAccess ORM). by condition with specific fields. Like set city = "Goa" where name = "atul".
Please review following swift code, it working fine. But how to do this by single query without using for loop.
func updateRecordsByName(userName: String) {
//like userName = atul;
let userArr : DBResultSet = User.query().whereWithFormat("name = %@", withParameters:[userName]).fetch();
for data in userArr {
(data as! User).city = "Goa";
(data as! User).commit();
}
}
Please suggest perfect solutions to reduce number of lines/loops and improve above query code.