Computer >> 컴퓨터 >  >> 프로그램 작성 >> MongoDB

Mongo 셸의 모든 컬렉션을 나열하는 방법은 무엇입니까?

<시간/>

Mongo 셸의 모든 컬렉션을 나열하려면 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;

다음은 출력입니다 -

ConvertStringToDateDemoIdUpdateDemoProductsInformationaddFieldDemoaddNewFieldToEveryDocumentarrayInnerElementsDemoarrayLengthGreaterThanOnearrayOfArraysDemocaseInsensitiveDemochangeDataTypechangeTypecharactersAllowedDemocharactersDemocheckFieldContainsStringDemocheckSequenceDemocombinationOfArrayDemoconditionalSumDemoconvertStringToNumberDemocopyThisCollectionToSampleDatabaseDemocountDemocreateSequenceDemodistinctCountValuesDemodistinctRecordDemodistinctWithMultipleKeysDemoemployeeInformationfilterArrayfindAllDuplicateKeyDocumentDemofindByMultipleArrayDemofindDuplicateByKeyDemofindDuplicateRecordsDemofindSpecificValuefindValueInArrayWithMultipleCriteriaDemogetLastNRecordsDemogetParticularElementFromArrayDemogetPartuclarElementgetSizeOfArraygroupByDateDemoincrementValueInNestedArrayDemoinsertIfNotExistsDemonestedArrayDemonotLikeOpeartorDemoregExpOnIntegerDemoremoveArrayDemoremoveArrayElementremoveArrayElementsremoveDuplicateDocumentDemoremoveElementFromDoublyNestedArrayDemoremoveFi를
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