This article mainly introduces Thinkphp's multi-condition query method using mongodb database, modified the mongodb driver file to implement composite query and multi-condition query. if you need it, refer to MongoDBThinkPHP.
One project uses the
mongo3.x, the host and port are useless and require a URI. (not tested)
URI = mongodb://host:port/Database
Mongo2.x supports both of the above configuration methods
mongo3.x only supports URI mode
3. TestingLaunch the app, start the MONGO service process, open swagger, and use Robomongo or Mongobooster client to observe MongoDB storage.The property is not set in Application.prop
In the past-blogs, the topic mainly focus on the high query operation of MongoDB. In this blog, we simply study the regex expression in the mongdb. MongoDB also support the Regex query. For exampleThe expression is also able to combination with other expression.Notes:/^a/; /^a.*/; /^a.*$/has the same result, however th
1. PrefaceIn this blog post, we will learn how to query the data in MongoDB. When we store the data in MongoDB, we need to query the data. After all, the query operation in the crud operation is our most frequently used operation in our system. We need to deal with different
Java Operations on MongoDB1.1 Even single MongoDBMongo mg = newMongo ();//default 127.0.0.1 port is 27017Mongo mg = newMongo (IP);//You can specify that the IP port defaults to 27017Mongo mg = newMongo (ip,port);//can also specify IP and port number1.2 Double-stage MongoDBIP is the host IP address, port is the port number, DatabaseName corresponds to the database nameDbaddress left = new Dbaddress ("Ip:port/databasename");Dbaddress right = new Dbaddre
We know that MongoDB is a non-relational database, so its query method is very different from the standard Structured Query Language SQL. But no matter how complicated it is, when it passes through the developer's hands, it can only become the structure that the customer wants. Today, we are going to talk about how to query
1 SummaryIn MySQL, the slow query log is often used as the basis for our query optimization, is there a similar function in MongoDB? The answer is yes, that is to turn on the profiling function. The tool collects writes about MONGODB, cursors, database commands, etc. on a running instance and can be opened at the datab
= $connection->baz->foobar;
?>
Insert a document
Multidimensional arrays are basic units that can be stored in a database
A random document might be like this
"Name" => "MongoDB",
"Type" => "database",
"Count" => 1,
"Info" => (object) Array ("X" => 203,
"Y" => 102),
"Versions" => Array ("0.9.7″," 0.9.8″, "0.9.9″")
);
?>
Note: You can nest arrays and objects, objects and documents are almost the same in MongoDB
MongoDB Java driver is thread-safe, for general applications, as long as a MONGO instance, MONGO has a built-in connection pool (pool size defaults to 10).
The following code gives you an introduction to the Java-driven operations of MongoDB, as shown in the following code:
Import java.util.ArrayList;
Import java
The content of the Pom.xml in HelloWorld's MAVEN project is
But what if you want to refer to a third party's library development? This article discusses this issue, taking MongoDB as an example, here does not introduce MongoDB, only know that he is a nosql, and there are client and server,
We will refer to MongoDB Library to realize
. Let's imagine a simple SQL self-defining function such as the following: function AddNumbers (x, y) {return x + y;}Here we convert this SQL-defined function into MongoDB's stored procedure: > Db.system.js.save ({_id: "AddNumbers", Value:function (x, y) {return x + y;}});: 2: Querying Stored ProceduresStored procedures can be viewed, changed, and deleted, so we use find to see if the stored procedure has been created. > Db.system.js.find (){"_id": "AddNumbers", "value": Function cf__1__f_ (x, y
("cust_id")]Public string CustomerId {get; set ;}/// /// Total/// [BsonElement ("amount")]Public int Amount {get; set ;}/// /// Status/// [BsonElement ("status")]Public string Status {get; set ;}} For the following operations based on the MongoDB GUI tool, see references 3.First, let's take a look at the parameters and results required for paging. The common parameters required for paging are:PageIndex current pageP
MongoDB uses find to query, returning a subset of the documents in a collection;Returns all documents in the Document collection blog:> Db.post.find () {"_id": ObjectId ("54a530c3ff0df3732bac1681"), "id": 2, "name": "Joe", "age": +, "sex": 1, "SCHool ":" Marry "} {" _id ": ObjectId (" 54a530c3ff0df3732bac1680 ")," id ": 1," name ":" Joe "," age ": +," comments ": [ "Test2", "Test9", "Test5"], "sex": 1, "sch
MongoDB slow query record in MySQL, the slow query log is often used as the basis for us to optimize the database, is there a similar function in MongoDB? The answer is yes, that's MONGO database. Profiler. Not only, but there are some more detailed information than the MySQL slow
Description: The optimization case is to express the meaning of the individual parameters, combining the analysis of the business with the logical implementation, and how to create the index and column order is selected (no longer described here)Environment Description :MongoDB version 3.0.9, replica set 3 node, memory 64g,cpu core, disk 2TB SSD, using WT storage engine ...The amount of data in this table is more than 260 million.The general analysis
This article is a blog post from MongoDB core developer @ kchodorow. It is the first article about MongoDB query puzzles. It introduces some query rules and usage of range query in Array through several examples. Assume that a Collection contains the following data: {x:-5} {
On the blog discussed, the database query data returned to the foreground JSP. The blog mainly uses Ajax calls to display a JSON string to get one of these fields, assigned to one of the controls in the interface.
That this blog, we explain, the backstage list pass JSP display.
List delivery interface, what we used to do in the past. A foreach El expression. or Java code.
So how do you show the list in JSON
->selectdb (' MyDB ')->selectcollection ("User");
Echo $dbCount();
? > Operation result is: 3 6, or operation of the query When querying, we may also use the or operation. The syntax format is as follows: $db->find (Array (' $or ' = = Array (' id ' = ' 1 '), Array (' name ' = ' java '))); For example above, our query ID is 1, or name is
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.