Introductory Remarks: db.keyword.distinct ("keyword"). length
As follows:
Db.keyword.distinct ("keyword"). length
View the total number of records in the keyword field in the keyword table without duplicates
This method is not seen in the
Use command
MongoDB use database_name
Used to create the database. The command creates a new database and returns the existing database if it does not exist.
Dropdatabase () method
MongoDB Db.dropdatabase ()
The command is used to delete an
Indexing is the most effective means of improving query query efficiency. An index is a special data structure that stores portions of the data in an easy-to-traverse format (for example, a specific field or set of field values), which sorts the
Exception in thread "main" java.lang.IllegalAccessError:tried to access method Org.bson.types.ObjectId. (III) V from class Org.mongojack.internal.stream.ObjectIdConvertor.
The cause of this problem is caused by a jar version
Overview
The _id field of MongoDB exists as a primary key at the top level of all documents, and _id must be unique and always have a unique constraint index. In addition to the unique constraint, you can use any value on the _id field in the
Use $set to specify a value for a key, and if it does not exist, create it. This is useful for updating patterns or adding user definitions.
Db.user.insert ({"Name": "Codingwhy.com"})
This user now only has the name information and now needs to
resolves a MongoDB cursor ID is not a valid at server issue
When you use Db.collection.find (), it returns not all data, but actually a "cursor". Its default behavior is to query the database for the first 101 documents, or 1 MB of documents,
Today, when configuring MongoDB, Win10 encountered a small problem, the configuration for the service is always not configured, the results found that the following command is not running as an administrator, resulting in failure.
Title Resolve MongoDB E11000 Duplicate key error collection: **.customer index:id dup key,Or the MongoDB atomicity problem, the code is as follows:
Collection.updateone (
New Document () Append ("_id", _id). Append ("$isolated", 1),
New
Gridfs is a file specification for storing large files in MongoDB:The MongoDB database holds binary objects in support of the Bson format , but the Bson objects in MongoDB cannot exceed 4MB in maximum.The GRIDFS specification provides a transparent
First, download and install MongoDB
1, official website download: https://www.mongodb.com/download-center#community
2. Installation
3, configure the path, as shown in the following image: Execute mongod.exe command, error "C:\data\db\ not
The MongoDB remove () function is used to remove data from the collection.
The update () function can be used for MONGODB data updates. It is a good practice to execute the Find () command before executing the Remove () function to determine if the
The example is based on the current latest MONGO driver, version Mongo-2.10.1.jar, and unit tests written in JUnit.
Testcase.java Java code package com.wujintao.mongo; import java.net.unknownhostexception; import java.util.arraylist;
Basic Operation command Show DBS//View all libraries using test//Use library without words automatically create show collections//view created table add Db.test_collection.insert (); Key value pair JSON data for (i=3;iDb.test.find ({$text: {$search:
MONGO Warning:
2016-09-05t10:55:13.241+0800 I CONTROL [initandlisten] * * WARNING:/sys/kernel/mm/transparent_hugepage/enabled is ' Always '.2016-09-05t10:55:13.241+0800 I CONTROL [initandlisten] * * We suggest setting it to ' never '2016-09-05t10:55
MongoDB Limit () method
If you need to read a specified number of data records in MongoDB, you can use the MongoDB limit method, and the limit () method accepts a numeric parameter that specifies the number of record bars read from MongoDB. Grammar
Transferred from: http://docs.mongoing.com/manual-zh/core/aggregation-pipeline-optimization.html
$skip + $limit order optimization
If you have a pipeline with $skip followed by a $limit, the optimizer moves the $limit to the front of the $skip, at
MongoDB implements MySQL auto_increment function
Refer to the official documentation (FINDANDMODIFY implementation):
1.Insert into the counters collection, the initial value for the UserID:
Db.counters.insert (
{
_id: "userid",
seq:0
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.