Closed
Description
New Feature / Enhancement Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
Current Limitation
Currently the developer needs to add a emptyObject to the ParseObject struct
Feature / Enhancement Description
Adding a Updatable protocol
Example Use Case
struct GameScore: ParseObject, Updatable {
//: Those are required for Object
var objectId: String?
var createdAt: Date?
var updatedAt: Date?
var ACL: ParseACL?
//: Your own properties.
var score: Int = 0
}
var changedScore = savedScore.updatable
changedScore.score = 200
changedScore.save { result in
switch result {
case .success(var savedChangedScore):
print("Succes")
case .failure(let error):
assertionFailure("Error saving: \(error)")
}
}
Alternatives / Workarounds
struct GameScore: ParseObject {
//: Those are required for Object
var objectId: String?
var createdAt: Date?
var updatedAt: Date?
var ACL: ParseACL?
//: Your own properties.
var score: Int = 0
/*:
It's recommended the developer adds the emptyObject computed property or similar.
Gets an empty version of the respective object. This can be used when you only need to update a
a subset of the fields of an object as oppose to updating every field of an object. Using an
empty object and updating a subset of the fields reduces the amount of data sent between
client and server when using `save` and `saveAll` to update objects.
*/
var emptyObject: Self {
var object = Self()
object.objectId = objectId
object.createdAt = createdAt
return object
}
}