Daily Study Notes (12)

Source: Internet
Author: User
Tags creative commons attribution mongodb server

1. Compile openfetion0 in the source code, install the required dependent libraries 1, install cmake, and build later than version 2.8 2. Create a build directory 3 under the openfetion directory, cmake-dcmake_install_prefix =/usr-dcmake_build_type = debug4. Go to the build directory to compile: Make installation: Make install5. If openfetion: Error while loading shared libraries: libofetion occurs after installation. so.0: cannot open shared object file: no such file or directory run ldconfig on the terminal

2. MongoDB Quick Start

1. Create the database storage directory/data/DB2 and go to the bin directory ,. /mongod start Server 3 ,. /Mongo start the shell window, here for preliminary study 4, shell is connected to the 'test' database by default, you can "use mydb" switch to mydb database MongoDB and will not create a database for you immediately, it is not created until the data is inserted on the first day. This "delayed creation" method provides better performance. This also means that if no data is inserted, "Show DBs" cannot be used to see empty databases. 5. Insert data to the database in the collection. foo. save ({name: "phinecos"}); dB. foo. find (); we do not need to define a set in advance. MongoDB will be automatically created when the first data is inserted. The stored documents can be of any structure, this means that the Database Upgrade and migration are simple. The above find () actually returns an iterator, VAR cursor = dB. foo. find (); While (cursor. hasnext () printjson (cursor. next (); you can also: DB. foo. find (). foreach (printjson); you can also think of the iterator as an array: printjson (cursor [3]); or simply convert it into an array: var arr = dB. foo. find (). toarray (); 6, query DB. foo. find ({Name: 'phinecos '}). foreach (printjson); it can be seen that the query condition itself is a document in the form of {A: A, B: B ,...} where a = A and B = B and... ". this query is equivalent to "select * From Foo where name = 'phinecos '". You can also query Only some fields of the document are returned for the query: DB. foo. find ({X: 4}, {J: true }). foreach (printjson); this will only display the Field J, which is equivalent to "select J From Foo where x = 4" DB. foo. findone ({Name: 'phinecos '}); in this way, only one document can be returned, and the limit method can be used to limit the number of returned results: DB. foo. find (). limit (3); 7, connection string MongoDB: // phinecos: 123 @ localhost/test connect to the local test using the username phinecos and password 123, the MongoDB server creates a thread for each TCP connection. Therefore, it is strongly recommended to use some form of connection pool in applications.

Author: Dongting sangren

Source: http://phinecos.cnblogs.com/

This blog complies with the Creative Commons Attribution 3.0 License. If it is used for non-commercial purposes, you can reprint it freely, but please keep the original author information and article URL.

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.