Since the blog program used by this blog is used by Edge development, some properties that are not needed are created dynamically during the development process.
MongoDB is Schema-free, unlike relational databases, where column properties are defined in tables rather than records, each document in a MongoDB collection can have different field properties.
MongoDB use Db.collections.update to modify the field properties of several documents in the collection, use $set to add fields, $unset delete the fields.
Deletes a field for all documents in the collection
Copy Code code as follows:
Db.posts.update ({}, {$unset: {deleted_at:1}}, {multi:true})
1. The first parameter indicates that some documents are selected, where {} indicates that all documents in the current posts collection are selected
2. The second parameter is a specific update operation, $unset represents the deletion of the domain
3. The third parameter is an additional option, {Multi:true} represents updating all documents that meet the requirements, and defaults to updating only the first
You can also delete multiple domains at the same time
Copy Code code as follows:
Db.categories.update ({}, {$unset: {deleted_at:1, desc:1}}, {multi:true})
also delete and add fields at the same time
Copy Code code as follows:
Db.tags.update (
{},
{$unset: {deleted_at:1}, $set: {slug:1, description:1}},
{Multi:true}
)