如何在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 婚礼结束聚餐祝福语简短
13 儿媳买车妈妈祝福语简短
14 毕业送礼老师祝福语简短
15 同事辞职正常祝福语简短
16 恭贺新婚文案祝福语简短
17 金店立秋祝福语简短英文
18 婆婆高寿祝福语大全简短