mongodb操作之使用javaScript实现多表关联查询

一、数据控制

  mongodb操作数据量控制,千万控制好,不要因为操作的数据量过多而导致失败。

  演示一下发生此类错误的错误提示:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAkEAAAC6CAIAAAAmrA4JAAAUvklEQVR4nO3da48TV57HcV7WvAVLxg9GSoKUOIJ0s9qlpNbIEi0srcST7XWmHXcGctFkyBrkhAnuhgAmsyEhzmXT2A4MgU7A4ZawM0XCTKJIfr4Pah+UXXVO1TnlKt+qDv396/MAyvapUxefn+sCtccZVffqdi5fAADAFHvIMACAocgwAICpyDAAgKnIMACAqcgwAICpyDAAgKnIMACAqcgwAICpyDAAgKnIMACAqcgwAICpyDAAgKnIMACAqcgwAICpyDAAgKnIMACAqcgwAICpYmbYRtdxHHsrly9Ue47j2M2VFPratCeetd9/T7Xn2Ju/m75Xs2pnzLIffbH53OivFaszKHfaxf2NUmdQbjWeXfy2WKBifVDuuPrLUzWlW2/P7bOP7kt7MQFMIv5x2EZ3lAFNO3GQNO1edRbdnWDW4f5PNN/Z9H/C9g887xx+xv+rtdxyh+CK1RmU65U5diwrrOVWf3m1XVq3pmtEs96qhw90D6S9jACSi8ywlS3be7UmZ1jNe2lcqAiNjJoavVTreRMDhzJN7zO2bQvZ42aYtem9HDn0a/rvfTx8/KSYr77/ynbcid2et2hSD6veZHtrmMcR68fr1VF5hLWWW+4QXLE6g9K6NZzS6Zfqg3JnYK26BxwDa3X05uHb8gX3EKTzYEX7fv8jikOf9b43vdQSXlJPHzZbDh0seodWpfWG5b+qn+/+RsldXrEdd6atxrPDhRr1Xzddsd68WXAoBpgpIsM2un4+SefipHN6K1t2dJAMP6J6T22j6r9BygYvFao96RygkGFjZ6rtf3guMearnZ2yHa97wTZ7G8J7/PiPPA57pvvy8/KrxbofXcoB2lr1xv18eOj3s035/vW+P77vb5S8ONnfKHntrLbLY6fnKsVVf6b+cY//Z+/AKB81X7/P+WI9cDrRjUl3YsXyD63U01XrzV/JwtlaAIb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dY4Fyfd89hLl9oHq8r76HXTRdbCx/VhafP+xl9AJBlWckwTGbez+gDgCwjw0w2/2f0AUCWkWEAAFORYQAAU5FhAABTkWEAAFORYQAAU5FhAABTkWEAAFNl+hmY6/2y+lEp83+mZeQzKgEAmZD1Z2DK/2Xi5O0kE/mMSgBARmTlGZjqZ12OMsw93vJfnfMzLSOeUQkAyI5MPANT86xL9yUvw8Rsm+8zLXXP9wIAZEoG7unQPScsX8h5x2eLfTAYGQYARjAgw+pta8FPZB7/jEoAQAZkIMO0z7oUXqrMIMYSPNNy7DMqAQAZkIkM0z3r0ru3frU9fGma2+gTPZc54hmVAICMyEaGAQCQHBkGADAVGQYAMBUZBgAwFRkGADDVmAxzHCf1LgIAoESGAQBMRYYBAExFhgEATBXMsOrhA87Lz3v/mQUZBgDILMVxWPXwge6B4Z/JMABAZikyzLJeJMMAANlHhgEATKW8p+OZ7ssHbOu3OTIMAJBhHIcBAExFhgEATMV9iQAAU/HvwwAApuL/6QAAmIoMAwCYigwDAJiKDAMAmIrnOAMATEWGAQBMRYYBAExFhgEATEWGAQBMRYYBAExFhgEATEWGAQBMRYYBAExFhgEATEWGAQBMRYYBAEz1/wzvQguC2FCGAAAAAElFTkSuQmCC" alt="" />

二、多表关联查询实现

/*
声明变量bridge,用来记录两个集合所连接的桥梁。
相当于sql语句中的Join on语句,on后边跟的条件。
有了桥梁以后,再进行关联那就是易如反掌的事情啦。
关联桥梁所存储的数据是什么样的类型就需要根据你自己的需求来进行创建了。
我这里用一个对象来作为桥梁,然后调用对象中的属性。
*/
var bridge = db.info.findOne();
/* javaScript语言是弱类型的语言,对于返回值是什么样的类型一定要做到心中有数。
在执行db.info.findOne()语句后,这里的返回值可以理解为一个对象,类似于一个javaBean
而在这里存储的所有的字段以及字段值(我用sql语句的说法更易理解)相当于对象的属性。 */ print(bridge.userid)
/*
使用print语句可以打印出上面语句返回的对象信息,进一步验证返回值是否如我们的猜测。
在这里userid这个字段本来是集合中的一个文档名称,即理解为一个表中的字段名称。
这里却相当于一个对象的属性。
*/ //循环用什么都可以,只要能够控制住次数,千万不要因为数据量太大而导致操作失败。
for(info = db.info.findOne({"userid":bridge.userid}),
//以上这句代码就是用来匹配集合中符合条件的,可以是任意mongodb的查询语句
//只要语句满足你的需求就可以,可以灵活变换。
error = db.warning.findOne({"userid":bridge.userid}),
//上边的这条语句同上
i = 0;i<1;i++){//这里就是控制循环次数的啦。
print(info,error);
//打印出我们匹配后的结果。
//关联查询如此简单。
}

我的查询结果:

  aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAhwAAABgCAIAAADZ4zy4AAASaklEQVR4nO2dy27jyBWG631mGTRA6RGmHyIwZQjwEwTZZZFkpiU3WkCAAbJLgixmNrIkYBiMPQIEO0FmMjGQaVtGI4K725YvfVMkq60bVWxnQYksUryUJFKHxTo/DhoyTfE/9VepPlN222Q8Ho/H49vrqx4KhUKhUOuJIFRQKBQKFZUQKigUCoWKTAgVFAqFQkUmGyr//MffsbCwsLCw1ikHVB641e/3v/zpfXv0kIT68qf3/J3HpH6/L5s1iK9UOQMOVjjFlxXsLPT7feGWAUIlGkm12QH6SpWz6ThVFCy2ArKKbxaghFBBqEhkjVDZjCP4Jp60CsgqvlmAkkRQubu7Q6i4ApHNGsRXqpxNR/BNPGkVkFV8swClu7s72AZWEEIlGkm12QH6SpWzCyobdk+apIVKr9cDbGAFIVSikVSbHaCvVDkjVFghVETRilDp9XoIFVcgslmD+EqVs+mIUDEVnEN8swO7p/d6vW63C9jACooHKqelX5Dsb04XjlfyRCkdCQSVVilLsqXWwnEt7zocwcrz8wrTStZanuS15Z8W5Ltq/2uZbrCBBEAlglkTVzJDhVIDsIdltSJUut0uQoU9HMFXE6vuiStZR7A9uX03ApWgwcbcwOa/YDQdESqmgqES3+zA3ih0u12xoTKd0tFYDy1Kjds373YO2vXOw3L1TZ48Kv1l2WeF1c5Bm7PzyKq6TTJPT52BrNTDWTFDctXVO1nVupYj25U1ElhjyNGarhtg6OxAjddytDbT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aDqj0lhF05yiUFALfxJNW0BOCChFCBYVKtMA38aQV9ISgQoRQQaFQKFRkQqigUCgUKjIhVFAoFAoVmRAqKBQKhYpM/wd6h1hBgcuxOgAAAABJRU5ErkJggg==" alt="" />

logtype其实就是我的集合名称。

综上:其实就两个点。

  1、明确桥梁

  2、控制循环,如果数据量小的话就不用控制了,我的数据量太多了。

不管你有多少表,我相信只要掌握住此思路,一定可以轻松的写出多表关联代码,轻松实现多表关联。

上一篇:C#中的HashSet, HashTable, Dictionary的区别【转】


下一篇:mongoDB操作详细