หากต้องการแสดงรายการคอลเลกชัน ให้ใช้ getCollectionNames() ใน MongoDB ต่อไปนี้เป็นไวยากรณ์ -
db.getCollectionNames();
ให้เราใช้ไวยากรณ์ข้างต้นเพื่อแสดงรายการชื่อคอลเลกชันทั้งหมดจากฐานข้อมูลทดสอบ -
> db.getCollectionNames();
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -
[ "arrayDemo", "arrayFieldIsNotEmptyDemo", "characterInFieldsDemo", "checkFieldExistDemo", "compareTwoFields", "comparingTwoFieldsDemo", "convertTextToDateTypeDemo", "countGroupByDemo", "demo407", "demo408", "demo409", "demo410", "demo411", "demo412", "demo413", "demo414", "demo415", "demo416", "demo417", "demo418", "demo419", "demo543", "demo544", "demo545", "demo546", "demo547", "demo548", "demo549", "demo550", "demo551", "demo552", "demo553", "demo554", "demo555", "demo556", "demo557", "demo558", "demo559", "demo560", "demo561", "demo562", "demo563", "demo564", "demo565", "demo566", "demo567", "demo568", "demo569", "demo570", "demo571", "demo572", "demo573", "demo574", "demo575", "demo576", "demo577", "demo578", "demo579", "demo580", "demo581", "demo582", "demo583", "demo584", "demo585", "demo586", "demo587", "demo588", "demo589", "demo590", "demo591", "demo592", "demo593", "demo594", "demo595", "demo596", "demo597", "demo598", "demo599", "demo600", "demo601", "demo602", "demo603", "demo604", "demo611", "demo612", "demo613", "demo614", "demo615", "demo616", "demo617", "demo618", "demo619", "demo620", "demo621", "demo622", "demo623", "demo624", "demo625", "demo626", "demo627", "demo628", "demo629", "demo630", "demo631", "demo632", "demo633", "demo634", "demo635", "demo636", "demo637", "demo638", "demo639", "demo640", "demo641", "employee", "getAllKeysDemo", "maxAttributePerGroup", "name", "objectArray", "order", "replaceSubstringDemo", "retriveAllStudents", "studentGetKeysDemo", "studentInformation", "totalDocumentDemo" ]