One, fixed set (Capped Collection)
The capped collections is an excellent set of fixed sizes, recently (aging out) processing with LRU (least Used age-out least used) rule and insertion order, automatically maintaining the insertion order of objects in the collection. Specify the size in advance when you create it. If the space is exhausted, the newly added object will replace the oldest object in the collection.
can be inserted and updated, but the update cannot exceed the collection size, or
The first thing to look at is GitHub's C + + driver projectHttps://github.com/mongodb/mongo-cxx-driverHere is a brief introduction, the current C + + driver is divided into three versions, placed in different branch
Branch
Stability
Development
Purpose
Master
Alpha
In progress
New c++11 Driver
Legacy
Stable
Stable Evolution
Primary Stable C + + driver re
Tags: www RDBMS equals closed blog alt start EXE 2.0 "Note: MongoDB automatically sets the _id field as the primary key" --------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------> Don't say a word, just start knocking at the command! "Note 1:mongodb command end do not hi
deferred execution in C #, such as: var list=db.person.find (); For such an operation, the list does not actually get the document in person, but instead declares a "query structure", which is passed when we need it. For or next () loads it once, and then lets the cursor read through the line, and when we're done enumerating, the cursor is destroyed, and then when we get through the list, found no data returned. Of course, our "query construction" can also make complex points, such as paging,
Because MongoDB is non-relational (join), references between documents ("Foreign keys") are usually solved by the client through additional queries to the server (linking ).
These connections are always resolved on the client. It is very easy to do this directly/manually and is recommended.
There is also a dbref mechanism that many drivers support. It abstracts the concept of linking to a certain extent.The recommended method is direct/manual link..
E
operation slower. nmoved: The file is operating on disk. nupdated: Update the number of documentsGetmore is a getmore operation, getmore usually occurs when the result set is larger than the query, the first query returns partial results, and subsequent results are obtained through Getmore.If the nscanned(number of records scanned) is much larger than nreturned(the number of records returning results), consider Gazzo to optimize record positioning. ResponseLength If it is too large, the result
Recently installed mongodb3.1.4, and enabled the authorization authentication, in DOS window operation without any problems, in order to maintain the convenience of downloading a client tool Robomongo 0.8.5, user name, password and other configuration good click Test, the result of connection service is not a problem, permission verification did not pass , as shown in the log, found a sentence: Failed to authenticate admin@admin with mechanism mongodb
Admindb.changeuserpassword ("username", "xxx")7. View user InformationDb.runcommand ({usersinfo: "UserName"})8. Change Password and user informationDb.runcommand ( { updateUser: "username", pwd: "xxx", customdata:{title: "xxx"} )Note:1. and user management related operations are basically to run under the Admin database, to use the admin first;2. If under a single database, it can only operate on the permissions of the current database;3.
Label:Preface: Daughter-in-law asked to be sent up. I want the first page of this article. 1,nuget introduced MongoDB. Then the namespace Using Mongodb.bson;
Using Mongodb.driver;
Using MongoDB.Driver.Builders;
Using MongoDB.Driver.Linq;
2, Global Declaration
Mongodatabase MONGO = new Mongoclient (configurationmanager.appsettings["Psconnstrmongodb"]). Getserver (). Getdatabase ("Psnew");
Mongocollection arts = NULL;
occurred;Exp:Db.stu.insert ({name: ' Zhangqiang ', Age16,sex: ' m ', weight:60});Db.stu.update ({$set: {Name:wangli}, $unset: {age:17}, $rename: {sex: ' Gender '}, $inc: {weight:2}}); optional parameter: {upsert:falsemulti:false} upsert: No matching rows are inserted directly into the row (if a field is queried to modify, otherwise new information is added) Muiti: Modify multiple rows (even if the query expression hits more than one line, and if you want to change multiple rows, add
transfer charges, based on Azure standard network rates:
Storage cost is relatively simple, according to their own data volume to estimate, then the RU cost how to calculate?AzureA single request unit is defined inRUused to represent reads (by self-linking orID) A containingTenunique attribute value (except for System properties).1 KBthe processing capacity required for the item. and1Kthe data is written to5aRU, a calculationRUThe examples are as follows: And for users to more easily calcu
Constraints-result set (transfer to Smart Network)Sometimes we just need to return some of the fields in the result set, which we can do by passing in the field conditions.
Grammar:
DB. Collection. Find( query condition, font condition )
Parameters:Field condition: JSON object, Format =>{field: value}, value equal to 1 indicates need to return, 0 indicates no need to return.
Example: Returns the "status" and "Age"
Not in the official MongoDB documentation, but is actually feasible and requires the following steps
1. Install key
Apt-key adv--keyserver hkp://keyserver.ubuntu.com:80--recv 7F0CEB10
2. Add a source
echo "Deb Http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.0 main" | sudo tee/etc/apt/sources.list.d/mongodb-org-3.0.list
Tags: mongodbNot in the official MongoDB documentation, but is actually feasible and requires the following steps1. Install keyApt-key adv--keyserver hkp://keyserver.ubuntu.com:80--recv 7F0CEB102. Add a sourceecho "Deb Http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.0 main" | sudo tee/etc/apt/sources.list.d/mongodb-org-3.0.list3. Update the sourceApt-get
Tags: mongodbAdd user error on MongoDB as follows:> Db.adduser (' User01 ', ' 123456 ');
2016-07-29t14:50:28.932+0800 E QUERY typeerror:property ' addUser ' of object admin is not a function at
(shell) : 1:4After the investigation, the reason is that in MongoDB version 3 has been deprecated adduser, changed to CreateUser.[[emailprotected]bin]$./mongo127.0.0.1:270
the UserID query in the Doctor table to the corresponding entry and pass the information into the req.body.doctorObject. As you can guess, this code is reusable. Of course, this code reuse situation will be more limited, because it is rough, on this point, the following will give a more comprehensive code of reuse. To run the command line in the project folder, run the command: Node Server.js If there are no errors, the following prompt is available: The hint content is defined in Server.js.
collection, using the $inc to add 1 to the age of name User1 in the collection, the other keys are the same, $inc means that a key value is added minus the specified value4. Update the document in the collection, $set the value used to specify a key, and if the key does not exist, create it.For example:To add an address to the document name User1, you can use the command:Db.c1.update ({name: "user1"},{$set: {address: "BJ"}},0,1)The document named User1 is modified to address TJ, the other key-v
nonexistent fields, reduce occupancy, increase speed! Introduce a thing first { field: { $exists: } } True to find M data FALSE to find data without M You cannot find a record on a sparse index that does not exist on this field, forcing the specified index. Hint (index name) Forces the specified index to be empty after the search results. 4. Location Index Category: 1.2D index filed by points on a plane 2.2Dsphere index filed by point on spherical surface Method: 1. Find points within
1. UpdateDb.persons.update ({name: "Caohui"},{id:2}); update only one, replace update directlyDb.persons.update ({name: "Caohui"},{id:2},true), update only one, replace update directly, insert if not present2. Full-scale updateDb.persons.update ({name: "Caohui"},{$set: {id:2}},false,true); full-scale local update3. $set {$set: {Field:value}}It is used to specify a key value pair, if there is a key value is modified, does not exist to add4. $inc {$inc: {Field:value}}Only used with numeric types,
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.