[SERVER-8777] update the data based on old values and new values with the same Unique Key Created: 28/Feb/13  Updated: 10/Dec/14  Resolved: 28/Oct/13

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Question Priority: Major - P3
Reporter: Shashank Tiwari Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-124 triggers Backlog
is related to SERVER-6566 Support conditional updates: $updates Closed
Participants:

 Description   

I have the problem
e.g. I already have a record in the mongodb as
{ "_id" :

{ "$oid" : "512dd8a3ac84a6e6e1af99c8"}

, "id" : 200 , "name" : "ESN000200" , "msg" : "hello world 298374" , "txPacket" : 445, "status": "up", "statusChanged": "yes" }
now I need to update this record.
I have to update the statusChanged field only if the status is changed else not.
what should be the better way to do this..?? I don't have previous information anywhere apart from this collection. What I can think of is get the value match and then put again but this will reduce the speed of updation. I need some oracle trigger like functionality



 Comments   
Comment by sam.helman@10gen.com [ 08/Mar/13 ]

Hello,

This is not currently possible server-side, but there are tickets open for this kind of behavior - see SERVER-124 and SERVER-6566. The easiest way to do this at the moment is to get the value, perform the logic client-side, and reupdate, as you have suggested.

What is the use pattern for checking if "statusChanged" is true? Is it another thread on the same client checking the value after the "status" field is changed, or another application? How often is the field checked?

Generated at Thu Feb 08 03:18:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.