Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> MongoDB

วิธี List Collections ใน MongoDB

การแสดงรายชื่อ Collections ทั้งหมด

เพื่อแสดงรายชื่อ Collections ให้ใช้ getCollectionNames() ใน MongoDB

Syntax

db.getCollectionNames();

ตัวอย่างการใช้งาน

> db.getCollectionNames();

ผลลัพธ์ (ตัวอย่างจาก Database test):

[
    "arrayDemo",
    "arrayFieldIsNotEmptyDemo",
    "characterInFieldsDemo",
    "checkFieldExistDemo",
    "compareTwoFields",
    "comparingTwoFieldsDemo",
    "convertTextToDateTypeDemo",
    "countGroupByDemo",
    "demo407",
    "demo408",
    ...
    "demo641",
    "employee",
    "getAllKeysDemo",
    "maxAttributePerGroup",
    "name",
    "objectArray",
    "order",
    "replaceSubstringDemo",
    "retriveAllStudents",
    "studentGetKeysDemo",
    "studentInformation",
    "totalDocumentDemo"
]