<small id='p0XMC'></small><noframes id='p0XMC'>

    <legend id='p0XMC'><style id='p0XMC'><dir id='p0XMC'><q id='p0XMC'></q></dir></style></legend>
      <bdo id='p0XMC'></bdo><ul id='p0XMC'></ul>

    1. <tfoot id='p0XMC'></tfoot>

        <i id='p0XMC'><tr id='p0XMC'><dt id='p0XMC'><q id='p0XMC'><span id='p0XMC'><b id='p0XMC'><form id='p0XMC'><ins id='p0XMC'></ins><ul id='p0XMC'></ul><sub id='p0XMC'></sub></form><legend id='p0XMC'></legend><bdo id='p0XMC'><pre id='p0XMC'><center id='p0XMC'></center></pre></bdo></b><th id='p0XMC'></th></span></q></dt></tr></i><div id='p0XMC'><tfoot id='p0XMC'></tfoot><dl id='p0XMC'><fieldset id='p0XMC'></fieldset></dl></div>

        mongodb 从不同的数据库中选择

        mongodb select from different databases(mongodb 从不同的数据库中选择)

        1. <legend id='q4eut'><style id='q4eut'><dir id='q4eut'><q id='q4eut'></q></dir></style></legend>
              <tbody id='q4eut'></tbody>

            <small id='q4eut'></small><noframes id='q4eut'>

              • <bdo id='q4eut'></bdo><ul id='q4eut'></ul>
                1. <tfoot id='q4eut'></tfoot>
                  <i id='q4eut'><tr id='q4eut'><dt id='q4eut'><q id='q4eut'><span id='q4eut'><b id='q4eut'><form id='q4eut'><ins id='q4eut'></ins><ul id='q4eut'></ul><sub id='q4eut'></sub></form><legend id='q4eut'></legend><bdo id='q4eut'><pre id='q4eut'><center id='q4eut'></center></pre></bdo></b><th id='q4eut'></th></span></q></dt></tr></i><div id='q4eut'><tfoot id='q4eut'></tfoot><dl id='q4eut'><fieldset id='q4eut'></fieldset></dl></div>
                  本文介绍了mongodb 从不同的数据库中选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有大约 200 个 mongodb 数据库.每个数据库都有一个名为Group"的集合,在这个集合中有一个名为meldingId"的字段.

                  I have about 200 mongodb databases. Every database has a collection called 'Group' and in this collection there is a field called 'meldingId'.

                  是否可以进行一个 mongodb 查询来查找不同数据库中的所有值.

                  Is it possible to make a one mongodb query which find all values in the different databases.

                  (我设法通过 selectDB($database_name) 选择数据库 bij 循环遍历数据库)

                  (I managed to select the databases bij looping through the databases by selectDB($database_name))

                  推荐答案

                  在 Mongo shell 中,这可以通过使用 db.getSiblingDB() 方法切换到管理数据库并通过运行获取 200 个数据库的列表管理命令 db.runCommand({ "listDatabases": 1 }).遍历数据库列表并使用 db.getSiblingDB() 再次在数据库之间切换,查询 Group 集合的 meldingId 值.像这样:

                  In Mongo shell, this can be done by using db.getSiblingDB() method to switch to admin database and get a list of the 200 databases by running the admin command db.runCommand({ "listDatabases": 1 }). Iterate over the list of databases and use db.getSiblingDB() again to switch between databases, query the Group collection for the meldingId values. Something like this:

                  // Switch to admin database and get list of databases.
                  db = db.getSiblingDB("admin");
                  dbs = db.runCommand({ "listDatabases": 1 }).databases;
                  
                  // Iterate through each database.
                  dbs.forEach(function(database) {
                      db = db.getSiblingDB(database.name);
                  
                      // Get the Group collection
                      collection = db.getCollection("Group");
                  
                      // Iterate through all documents in collection.
                      /*
                          collection.find().forEach(function(doc) {
                  
                              // Print the meldingId field.
                              print(doc.meldingId);
                          });
                      */
                  
                      var meldingIds = collection.distinct('meldingId');
                      print(meldingIds);
                  
                  });
                  

                  这篇关于mongodb 从不同的数据库中选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Is Joomla 2.5 much faster than Joomla 1.5 Querywise(Joomla 2.5 比 Joomla 1.5 Querywise 快得多吗)
                  How to share Joomla login session from one joomla website to one ASP.Net MVC website(如何将 Joomla 登录会话从一个 joomla 网站共享到一个 ASP.Net MVC 网站)
                  htaccess redirect root to subdirectory but allow index.php in root AND query strings to function(htaccess 将根重定向到子目录,但允许根和查询字符串中的 index.php 起作用)
                  Joomla include database functions(Joomla 包含数据库功能)
                  nl2br() not working when displaying SQL results(显示 SQL 结果时 nl2br() 不起作用)
                  Joomla 2.5 JFactory::getSession(); seems to be caching in firefox(Joomla 2.5 JFactory::getSession();似乎在 Firefox 中缓存)
                2. <legend id='OdyPA'><style id='OdyPA'><dir id='OdyPA'><q id='OdyPA'></q></dir></style></legend>

                    <tbody id='OdyPA'></tbody>

                    <tfoot id='OdyPA'></tfoot>
                  • <small id='OdyPA'></small><noframes id='OdyPA'>

                      1. <i id='OdyPA'><tr id='OdyPA'><dt id='OdyPA'><q id='OdyPA'><span id='OdyPA'><b id='OdyPA'><form id='OdyPA'><ins id='OdyPA'></ins><ul id='OdyPA'></ul><sub id='OdyPA'></sub></form><legend id='OdyPA'></legend><bdo id='OdyPA'><pre id='OdyPA'><center id='OdyPA'></center></pre></bdo></b><th id='OdyPA'></th></span></q></dt></tr></i><div id='OdyPA'><tfoot id='OdyPA'></tfoot><dl id='OdyPA'><fieldset id='OdyPA'></fieldset></dl></div>

                          <bdo id='OdyPA'></bdo><ul id='OdyPA'></ul>