-
Type: Improvement
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: 1.4.4
-
Component/s: API
-
None
-
Environment:Linux
Currently I am needing to do this:
2148 // start host modification atomicity
2149 // that is required because the host outsideIp may be updated twice once before the change and once after
2150 // yet before the read for checking if the IP changed
2151
2152 updateResult, err := collection.UpdateOne(context.TODO(), filter, update)
2153 if err != nil
{ 2154 _ = updateResult 2155 fmt.Printf("\n\nerror in wss config request when updating host: %s\n", err) 2156 }2157
2158 //fmt.Printf("Matched %v documents and updated %v documents.\n", updateResult.MatchedCount, updateResult.ModifiedCount)
2159
2160 // compare this_host.OutsideIp and the update result.outsideIp to see if a new entry was added
2161 // if an entry was added, increment the host document's outsideIpChangesPerDay field
2162 var updated_host Host
2163 err = collection.FindOne(context.TODO(), filter).Decode(&updated_host)
2164
2165 fmt.Printf("this_host.outsideIp: \t%+v\nupdated_host.outsideIp: \t%v\n\n", this_host.OutsideIp, updated_host.OutsideIp);
2166
2167 if (updated_host.OutsideIp[0] != this_host.OutsideIp[0])
{ 2168 2169 // increment outsideIpChangesPerDay 2170 2171 }2172
2173 // end host modification atomicity
If line 2152 (collection.UpdateOne) returned the updated document with regards to not allowing another update before returning (ie atomic) then I would not have to start and end atomicity on the routine...
Thanks.