Database hiện tại chứa dữ liệu mẫu sample_analytics (các collection accounts, customers, transactions). Hãy tạo một báo cáo gồm 3 phần:
db.getCollectionNames().sort()).accounts, customers, transactions: số document countDocuments({}).transactions: dung lượng dữ liệu logic stats().size (byte) và số index stats().nindexes.Lưu ý: không dùng show collections, db.stats() hay in toàn bộ stats(); các chỉ số dung lượng lưu trữ thực tế (storageSize, totalIndexSize()) thay đổi theo mỗi lần chạy nên không dùng trong bài này. Chương trình chỉ in đúng 6 dòng ở phần Output.
Các collection accounts, customers, transactions (dữ liệu mẫu sample_analytics) đã được nạp sẵn vào database hiện tại.
In đúng 6 dòng, theo thứ tự:
[ 'a', 'b', 'c' ]countDocuments({}) của accountscountDocuments({}) của customerscountDocuments({}) của transactionsstats().size của transactionsstats().nindexes của transactionsMỗi số in trên một dòng (biểu thức đứng riêng trong mongosh hoặc print(...)).
Ví dụ:
Đầu vào:
sample_analytics.accounts
sample_analytics.customers
sample_analytics.transactions
Đầu ra:
[ 'accounts', 'customers', 'transactions' ]
1746
500
1746
16138269
1
Đang tải editor...