First, Data control
MongoDB operation of data volume control, do not control, because the operation of the data volume is too large to cause failure.
Demonstrate the error message that occurs with this type of error:
Implementation of multi-table association query
/* Declare variable bridge, which is used to record the bridges connected by two sets. Equivalent to the join ON statement in the SQL statement, on the following condition. With a bridge, it's easy to get connected again. The type of data stored by the associated bridge needs to be created according to your own needs. I use an object here as a bridge, and then call the properties in the object. */var bridge = Db.info.findOne ();/*javascript language is a weakly typed language, so be sure to be aware of what type of return it is. After executing the Db.info.findOne () statement, the return value here can be understood as an object, similar to a JavaBean, and all fields stored here and field values (which I can easily understand with the SQL statement) are equivalent to the properties of the object. */print (Bridge.userid)/* Use the PRINT statement to print out the object information returned by the above statement, further verifying that the return value is as we guessed. Here userid This field is originally a document name in the collection, which is understood as a field name in a table. This is equivalent to the property of an object. *///loop with anything, as long as you can control the number of times, do not because the data volume is too large to cause the operation failed. for (info = Db.info.findOne ({"userid": Bridge.userid}),/ /The above code is used to match the criteria in the set, can be any MONGODB query statement // As long as the statement meets your needs, you can change it flexibly. error = Db.warning.findOne ({"userid": Bridge.userid}), //above this statement above i = 0;i<1;i++) {//Here is the number of control loops. print (info,error); Print out the results of our match. //Correlation query is so simple. }
My query results:
LogType is actually my collection name.
In fact, there are two points.
1, Clear Bridge
2, control the cycle, if the amount of data is small, then do not control, my data volume is too much.
No matter how many tables you have, I believe that as long as you master this idea, you can easily write multi-table association code, easy to implement multi-table association.
MongoDB operation using JavaScript to implement multi-table association query