Modification
Make changes on existing data. MongoDB doesn't restrict data stored in the same format. For convenience, in insert functions I kept data format the same. Fixed structure make query easy. Otherwise, for example, query strings in key "breath" is difficult. "breath" contains nested object. The key names under breath are barely the same.With update $set and $unset, I can completely change the structure of existing records.
Update $set
Set values on qualified records. $set object can contain more than one data set.
At this example, I
- changed style from Array to String.
- added new object into key-breath, expanded its branches.
- added another branch-song at record root.
After update, this record owned a structure different from others.
Update $unset
Unset specific keys. Everything under this key would be removed. $unset object can contain multiple keys, set value to 0 to remove data set. Here I
- removed key-style
- removed key-breath which contained nested objects.
For now, except query on key-name, what applied to other records wouldn't apply to this modified record. It contains different keys.
Delete Records
Delete records,
Drop Collection
Drop collection. And then use db function listCollections() to check the result.
Great Resources
NodeJS APIs for MongoDB: http://mongodb.github.io/node-mongodb-native/3.5/api/index.htmlMongoDB Commands: https://docs.mongodb.com/manual/reference/method/
Comments
Post a Comment