Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
swapping data in mongodb
#1
I have created a mongodb collection in python django.The collection name is audit_details and it consists of following data
Output:
_id:630e026211cb34947c85a7a5 user:"akhil" status:null old_data:null new_data:2022-08-30T17:58:18.551+00:00 _id:630e026211cb34947c85a7a6 user:"sandeep" status:null old_data:null new_data:2022-08-30T17:58:18.551+00:00
now,i want the new_data value to be assigned to "old_data" and the "new_data" will take the "updated_time" value taken from API post request(I am using django restframework and the data i am sending as post request is {"action":"modify","user":"sandeep,"updated_time":"2022-08-26 16:26:00"})

i want the output to be like below
Output:
_id:630e026211cb34947c85a7a6 user:"sandeep" status:modified old_data:migration was scheduled at 2022-08-30T17:58:18.551+00:00 new_data:migration now scheduled at "2022-08-26 16:26:00"
is it possible to achieve this in mongodb?I am using mongo latest version
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Exclamation MongoDB cannot connect - pymongo speedev 1 2,096 Aug-21-2021, 01:35 PM
Last Post: ndc85430
Bug Djongo (mongoDb) - Django rest framework Problem with search on JsonFields grzybekrafal 0 2,479 May-11-2021, 09:04 AM
Last Post: grzybekrafal
  Retrieve data from MongoDB dsuk 2 2,304 Aug-24-2020, 09:22 PM
Last Post: micseydel
  find a string in a field in MongoDB Leon79 2 2,449 Jul-19-2020, 09:20 PM
Last Post: menator01
  insert more data at once in MongoDB Leon79 2 2,354 Jul-05-2020, 01:34 PM
Last Post: Leon79
  Load JSON file data into mongodb using pymongo klllmmm 1 11,880 Jun-28-2019, 12:47 AM
Last Post: klllmmm
  Collecting Data from Twitter with Tweepy and MongoDB fatony 1 3,926 Apr-10-2017, 09:38 PM
Last Post: fatony

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020