在MongoDB码头,我如何列出Im使用的现有数据库的所有收集资料?
How can I deploy a Django project that uses MongoDB to AWS? I have a project made using Django and have been using MongoDB and its Compass app and was wondering if you could deploy said project and ...
在MongoDB码头,我如何列出Im使用的现有数据库的所有收集资料?
......
Java:
db.getCollectionNames()
Node.js:
db.listCollections()
非贾瓦文(仅举):
show collections
我的理由是:
$ mongo prodmongo/app --eval "show collections"
MongoDB shell version: 3.2.10
connecting to: prodmongo/app
2016-10-26T19:34:34.886-0400 E QUERY [thread1] SyntaxError: missing ; before statement @(shell eval):1:5
$ mongo prodmongo/app --eval "db.getCollectionNames()"
MongoDB shell version: 3.2.10
connecting to: prodmongo/app
[
"Profiles",
"Unit_Info"
]
如果你真的想要这一轮,,那么你可以:
$ mongo prodmongo/app --eval "db.getCollectionNames().join(
)"
MongoDB shell version: 3.2.10
connecting to: prodmongo/app
Profiles
Unit_Info
> show collections
如指挥线帮助所述,将列出目前选定的非行的所有收集资料(<条码>求助代码>)。
我如何列出Im使用的现有数据库的所有收集资料?
show collections
show tables
db.getCollectionNames()
show dbs
use databasename
show collections
产出:
collection1 collection2 system.indexes
(或)
show tables
产出:
collection1 collection2 system.indexes
(或)
db.getCollectionNames()
产出:
[ "collection1", "collection2", "system.indexes" ]
use collectionname
<代码>>
其结果与卡梅伦的答复相同。
除其他人提出的选择外:
show collections // Output every collection
show tables
db.getCollectionNames() // Shows all collections as a list
如果你想要知道如何建立每项收集资料,也可以真正地讲出另一种方式(例如,它是一种带有一定规模的限定收集):
db.system.namespaces.find()
首先,你们需要利用一个数据库来展示其内部的所有收集/表。
>show dbs
users 0.56787GB
test (empty)
>db.test.help() // this will give you all the function which can be used with this db
>use users
>show tables //will show all the collection in the db
Try:
help // To show all help methods
show dbs // To show all dbs
use dbname // To select your db
show collections // To show all collections in selected db
您可使用<条码> tables表条码>或<条码>。
1. show collections; // Display all collections
2. show tables // Display all collections
3. db.getCollectionNames(); // Return array of collection. Example :[ "orders", "system.profile" ]
每次收集的详细信息:
db.runCommand( { listCollections: 1.0, authorizedCollections: true, nameOnly: true } )
根据搜查令列出收集清单。
db.getCollectionNames().filter(function (CollectionName) { return /<Search String>/.test(CollectionName) })
<>>Example: 以“进口”名义进行的所有收集
db.getCollectionNames().filter(function (CollectionName) { return /import/.test(CollectionName) })
我认为,最大的混淆之一是你在<条码>mongo/code>(或互动/冲锋利)诉<条码>mongo-eval(或纯 Java本壳)方面所能做的区别。 我保存这些有益的文件:
这方面的一个例子是,你可能与<代码>show做些什么。 指挥:
# List all databases and the collections in them
mongo --eval "
db.getMongo().getDBNames().forEach(
function(v, i){
print(
v +
+
db.getSiblingDB(v).getCollectionNames().join(
)
)
}
)
"
说明:这项工作确实是一行。 (它看上去的是斯纳克多里。)
mongo --eval "db.getMongo().getDBNames().forEach(function(v, i){print(v+
+db.getSiblingDB(v).getCollectionNames().join(
))})"
邦戈舒尔的以下指挥是司空见惯的。
show databases
show collections
此外,
show dbs
use mydb
db.getCollectionNames()
有时,看到所有收集资料以及作为总名称空间一部分的收集索引是有益的:
在这方面,你将如何做到:
db.getCollectionNames().forEach(function(collection) {
indexes = db[collection].getIndexes();
print("Indexes for " + collection + ":");
printjson(indexes);
});
在三军司令部和这支军之间,你应被很好地涵盖!
If you want to show all collections from the MongoDB shell (command line), use the shell helper,
show collections
that shows all collections for the current database. If you want to get all collection lists from your application then you can use the MongoDB database method
db.getCollectionNames()
关于MongoDB助手的更多信息,请见mongo
。壳牌Quick Reference。
> show dbs
anuradhfirst 0.000GB
local 0.000GB
> use anuradhfirst
switched to db anuradhfirst
> show collections
record
mongo
. This will start the connection.show dbs
command. This will show you all exiting/available databases.database
you want. In the above it is anuradhfirst
. Then run use anuradhfirst
. This will switch to the database you want.show collections
command. This will show all the collections
inside your selected database.改用数据库。
:
<><>strong>use{your_database_name} 例如:
use friends
where friends
is the name of your database.
然后写:
db.getCollectionNames()
show collections
这将使你获得收藏品的名称。
On;=2.x,你可以做
db.listCollections()
1. 你们可以做些什么
db.getCollectionNames()
www.un.org/Depts/DGACM/index_spanish.htm 登记在<代码>mongo上的所有收藏品:
- db.getCollectionNames()
- show collections
- show tables
Note: Collections will show from current database where you are in currently
放映
这支指挥部通常在MongoDB飞机上工作,一旦你转至数据库。
任何人使用<> 甲型六氯环己烷
<编码>db.list_ Collection_names(>
For MongoDB 3.0 deployments using the WiredTiger storage engine, if you run
db.getCollectionNames()
from a version of the mongo shell before 3.0 or a version of the driver prior to 3.0 compatible version,db.getCollectionNames()
will return no data, even if there are existing collections.
详情请见。
利用<代码>mongo的以下指挥系统: 页: 1
show collections
为此,我使用<条码>。
例:
db.runCommand({ listCollections: 1, filter: {}, nameOnly: true });
收集指数等更多信息:
db.runCommand({ listCollections: 1, filter: {}, nameOnly: false });
仅印刷收集名称:
db.runCommand({ listCollections: 1, filter: {}, nameOnly: true }).cursor.firstBatch.forEach(v => {print(v.name)})
我认为这提供了更大的灵活性。
show collections
或
show tables
或
db.getCollectionNames();
How can I deploy a Django project that uses MongoDB to AWS? I have a project made using Django and have been using MongoDB and its Compass app and was wondering if you could deploy said project and ...
Whats the best way to access/query a DB Ref: UPDATE: users: name, groupref : {$ref:"groups",$id:"ObjectId ..." } } groups: name, topic, country,...,.. Assumption is that user belongs to only one ...
Example: > db.stuff.save({"foo":"bar"}); > db.stuff.find({"foo":"bar"}).count(); 1 > db.stuff.find({"foo":"BAR"}).count(); 0
What re the best practices to store nested sets (like trees of comments) in MongoDB? I mean, every comment can have a parent comment and children-comments (answers). Storing them like this: { ...
I ve been using the following web development stack for a few years: java/spring/hibernate/mysql/jetty/wicket/jquery For certain requirements, I m considering switching to a NoSQL datastore with an ...
I m building a Rails application using MongoDB as the back-end and MongoMapper as the ORM tool. Suppose in version 1, I define the following model: class SomeModel include MongoMapper::Document ...
I have the following setup: Mac Pro with 2 GB of RAM (yes, not that much) MongoDB 1.1.3 64-bit 8 million entries in a single collection index for one field (integer) wanted Calling .ensureIndex(...) ...
My application creates pieces of data that, in xml, would look like this: <resource url="someurl"> <term> <name>somename</name> <frequency>somenumber</...