What do you do with the original data after mongodb adjusts the schema?

after mongodb has designed the schema, it has been running normally for some time (data is already available). When you adjust the schema later, for example, to add a field and decrease a field, what to do with the original data? do you have to wash the data first? Or.

Mar.30,2021

after schema has been designed
if you want to add fields, execute the mongo command: db.yourtable.update ({}, {$set: {addField: ""}, false,true)
if you want to delete fields, execute the mongo command: `field ({}, {$unset: {deleteField: ""}, false,true)

Note: if the amount of data in the table is too large, you can consider adding some Filter conditions at query to achieve the effect of batch execution.


the original data is still there, so you can delete it one by one or modify it one by one. If the data is huge, you can directly do error compatibility processing, which is less. The table of the field needs to be handled specially.
the best thing, of course, is to be consistent with schema, so it's best to replace all data

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b353a7-40504.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b353a7-40504.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?