MongoDB change, delete a document's Domain property instance

Source: Internet
Author: User
Tags comparison table install mongodb mongodb collection

MongoDB change, delete a document's Domain property instance

In the development of the site, the initial design may not be reasonable. Or late-business changes can create a somewhat useless property for the document structure. Need to be removed or altered. Because MongoDB is Schema-less, unlike relational databases, column properties are defined in tables rather than records, and each document in a MongoDB collection can have its own domain properties. MongoDB uses db.collections.update to change the domain properties of several documents in the collection, using $set to add fields. $unset Delete the domain.
Delete a field from all documents in the collection

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 detailed update operation, $unset means to delete the domain

3. The third parameter is an additional option. {Multi:true} means that all documents that meet the requirements are updated, and the first one is only updated by default

can also delete multiple domains at the same time

Db.categories.update ({}, {$unset: {deleted_at:1, desc:1}}, {multi:true})


also delete and add domains at the same time

Db.tags.update (    {},    {$unset: {deleted_at:1}, $set: {slug:1, Description:1}},    {multi:true})

This article: http://www.lai18.com/content/348300.html, digression: There are a very large number of people are not optimistic about MongoDB, and even listed a lot of MongoDB problems. In fact, MongoDB is just a tool, and what we need is that it can help us to solve the demand, believing MongoDB will be getting better .
Read "MongoDB Technical Knowledge" series of technical Articles to organize the collection

1Basics to get started with MongoDB

2MongoDB Beginner Tutorials (including installation, frequently used commands, related concepts, usage tips, common operations, etc.)

3MongoDB Novice Tutorial of the Shard technology specific explanation

Introduction to the frequently used operations and maintenance technology for 4MongoDB novice Tutorials

5MongoDB Beginner's Tutorial C # driver Operation example

6MongoDB Novice Tutorial of the master-slave replication Configuration specific explanation

Introduction to the aggregation and cursor operation of the 7MongoDB beginner tutorial

8MongoDB Novice Teaching procedures to detail the MongoDB database additions and deletions to check and change the operation

An analysis of the index operation of 9MongoDB Novice Tutorial

10MongoDB Novice Tutorial of the MongoDB database installation diagram under Windows

11MongoDB query field does not create an index caused by Connection Timeout exception solution case sharing

12MongoDB log file is too large a workaround

13MongoDB Community Edition and Enterprise Edition difference comparison table

14MongoDB Chinese Community Initiator takes you to learn MongoDB.

Analysis on performance bottleneck of 15 MongoDB database

The method and performance of 16MongoDB paging query

Cluster architecture implementation of 17MongoDB Shard storage

18Mongodb Bulk deletion of Gridfs file instances

19Mongodb adding, removing Shard server instances

20Mongodb adding, removing Arbiter node instances

MongoDB Installation and configuration tutorial under 21CentOS system

22MongoDB changing, deleting a document's Domain attribute instance

MongoDB basic operations in 23Python: connecting, querying instances

24MongoDB Export Query results to file sample

Things to consider when creating indexes in 25MongoDB

Some pits in 26MongoDB (best not to use)

27 adding user rights to MongoDB sharing method

Simple installation and basic operation of MongoDB under 28Linux system

Basic management commands for the 29MongoDB tutorial

Aggregation of 30MongoDB Tutorials (count, distinct, and group)

Introduction to the index of 31MongoDB tutorials

Data manipulation examples of 32MongoDB tutorials

Basics of getting Started with 33MongoDB tutorials

Examples of query operations for 34MongoDB tutorials

35MongoDB Series Tutorial (iv): Set User access permissions

36MongoDB Series Tutorials (eight): Gridfs Storage Specific explanations

Introduction to the features and strengths of 37MongoDB databases

38MongoDB a brief introduction to the five features of MongoDB

39MongoDB Series Tutorial (vi): Java operation MongoDB Instance

40MongoDB Series Tutorial (vii): Specific explanation of MONGODB data structure

41MongoDB Series Tutorial (v): MONGO Grammar and MySQL grammar control learning

42MongoDB Series Tutorial (ii): MongoDB Brief Introduction

43MongoDB Series Tutorial (i): NoSQL origins

A simple introduction to MapReduce in 44MongoDB

45MongoDB Series Tutorial (iii): Download and install MongoDB in Windows

46 on how to back up MongoDB

47MongoDB frequently Used command summary

48MongoDB and MySQL operation control table and difference introduction

49MongoDB Security Configuration Specific explanation

Bson Introduction and usage examples in 50MongoDB


MongoDB change, delete a document's Domain property instance

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.