如何在Mongo Shell中列出所有集合?
要列出Mongoshell中的所有集合,可以使用函数getCollectionNames()。
语法如下-
db.getCollectionNames();
您可以使用另一个命令即集合。语法如下-
show collections;
要列出Mongo中的所有集合,请使用以上两个函数。查询如下-
> db.getCollectionNames();
以下是输出-
[ "ConvertStringToDateDemo", "IdUpdateDemo", "ProductsInformation", "addFieldDemo", "addNewFieldToEveryDocument", "arrayInnerElementsDemo", "arrayLengthGreaterThanOne", "arrayOfArraysDemo", "caseInsensitiveDemo", "changeDataType", "changeType", "charactersAllowedDemo", "charactersDemo", "checkFieldContainsStringDemo", "checkSequenceDemo", "combinationOfArrayDemo", "conditionalSumDemo", "convertStringToNumberDemo", "copyThisCollectionToSampleDatabaseDemo", "countDemo", "createSequenceDemo", "distinctCountValuesDemo", "distinctRecordDemo", "distinctWithMultipleKeysDemo", "employeeInformation", "filterArray", "findAllDuplicateKeyDocumentDemo", "findByMultipleArrayDemo", "findDuplicateByKeyDemo", "findDuplicateRecordsDemo", "findSpecificValue", "findValueInArrayWithMultipleCriteriaDemo", "getLastNRecordsDemo", "getParticularElementFromArrayDemo", "getPartuclarElement", "getSizeOfArray", "groupByDateDemo", "incrementValueInNestedArrayDemo", "insertIfNotExistsDemo", "nestedArrayDemo", "notLikeOpeartorDemo", "regExpOnIntegerDemo", "removeArrayDemo", "removeArrayElement", "removeArrayElements", "removeDuplicateDocumentDemo", "removeElementFromDoublyNestedArrayDemo", "removeFieldCompletlyDemo", "removeObject", "renameFieldDemo", "reverseRegexDemo", "searchArrayDemo", "selectSingleFieldDemo", "singleFieldDemo", "sortDemo", "sortInnerArrayDemo", "sourceCollection", "stringFieldLengthDemo", "test.js", "uniqueIndexOnArrayDemo", "unwindOperatorDemo", "updateExactField", "updateIdDemo", "updateObjects" ]
这是第二个查询,显示来自Mongo的所有集合。查询如下-
> show collections;
以下是输出-
ConvertStringToDateDemo IdUpdateDemo ProductsInformation addFieldDemo addNewFieldToEveryDocument arrayInnerElementsDemo arrayLengthGreaterThanOne arrayOfArraysDemo caseInsensitiveDemo changeDataType changeType charactersAllowedDemo charactersDemo checkFieldContainsStringDemo checkSequenceDemo combinationOfArrayDemo conditionalSumDemo convertStringToNumberDemo copyThisCollectionToSampleDatabaseDemo countDemo createSequenceDemo distinctCountValuesDemo distinctRecordDemo distinctWithMultipleKeysDemo employeeInformation filterArray findAllDuplicateKeyDocumentDemo findByMultipleArrayDemo findDuplicateByKeyDemo findDuplicateRecordsDemo findSpecificValue findValueInArrayWithMultipleCriteriaDemo getLastNRecordsDemo getParticularElementFromArrayDemo getPartuclarElement getSizeOfArray groupByDateDemo incrementValueInNestedArrayDemo insertIfNotExistsDemo nestedArrayDemo notLikeOpeartorDemo regExpOnIntegerDemo removeArrayDemo removeArrayElement removeArrayElements removeDuplicateDocumentDemo removeElementFromDoublyNestedArrayDemo removeFieldCompletlyDemo removeObject renameFieldDemo reverseRegexDemo searchArrayDemo selectSingleFieldDemo singleFieldDemo sortDemo sortInnerArrayDemo sourceCollection stringFieldLengthDemo test.js uniqueIndexOnArrayDemo unwindOperatorDemo updateExactField updateIdDemo updateObjects
热门推荐
10 诗词送行祝福语大全简短
11 新房开工吉日祝福语简短
12 50多岁生日简短祝福语
13 安徽疫情祝福语简短英语
14 农民朋友发财祝福语简短
15 对生活祝福语简短精辟
16 搬家词简短祝福语朋友
17 女神结婚快乐祝福语简短
18 文学短句祝福语大全简短