query="UPDATE storage SET value = $4, version = $5, read = $6, write = $7, update_time = now() WHERE collection = $1 AND key = $2 AND user_id = $3::UUID"
}else{
// Inserting a new storage object.
switch{
caseobject.Version!=""&&object.Version!="*":
// OCC if match.
query="UPDATE storage SET value = $4, version = $5, read = $6, write = $7, update_time = now() WHERE collection = $1 AND key = $2 AND user_id = $3::UUID AND version = $8"
params=append(params,object.Version)
// Respect permissions in non-authoritative writes.
if!authoritativeWrite{
query+=" AND write = 1"
}
casedbVersion.Valid&&object.Version!="*":
// An existing storage object was present, but no OCC if-not-exists required.
query="UPDATE storage SET value = $4, version = $5, read = $6, write = $7, update_time = now() WHERE collection = $1 AND key = $2 AND user_id = $3::UUID AND version = $8"
params=append(params,dbVersion.String)
// Respect permissions in non-authoritative writes.
if!authoritativeWrite{
query+=" AND write = 1"
}
default:
// OCC if-not-exists, and all other non-OCC cases.