Trong collection customers, truy vấn các customer có mảng accounts tồn tại và số phần tử ≥ 2 (gợi ý: $size trong $expr, hoặc kiểm tra phần tử thứ hai accounts.1 tồn tại).
Yêu cầu hiển thị:
name, accounts (không hiển thị _id).name tăng dần; nếu cùng name thì theo _id tăng dần.use. Chương trình chỉ được in kết quả của một câu truy vấn này.Collection customers (dữ liệu mẫu sample_analytics.customers) đã được nạp sẵn.
Kết quả của câu find theo định dạng mongosh: một mảng 10 document gồm name, accounts. Ví dụ phần đầu:
[
{
name: 'Aaron Perez',
accounts: [ 744220, 126092, 187107, 437371, 413293 ]
},
...
]
Ví dụ:
Đầu vào:
sample_analytics.customers
Đầu ra:
[
{
name: 'Aaron Perez',
accounts: [ 744220, 126092, 187107, 437371, 413293 ]
},
{ name: 'Adam Anderson', accounts: [ 945232, 858473, 831600, 951500 ] },
{
name: 'Alex Chandler',
accounts: [ 385361, 506711, 719203, 882090, 569420, 546211 ]
},
{ name: 'Alex Turner', accounts: [ 61329, 87437, 972041, 632303 ] },
{ name: 'Alexander Goodman', accounts: [ 418570, 895006 ] },
{ name: 'Alexander Hernandez', accounts: [ 415928, 525530 ] },
{ name: 'Alexis Miller', accounts: [ 635729, 784910, 600800, 741762 ] },
{
name: 'Alvin Larson',
accounts: [ 402535, 833855, 994562, 951224, 415759 ]
},
{ name: 'Alyssa Bailey', accounts: [ 358133, 54977 ] },
{
name: 'Amanda Best',
accounts: [ 87191, 642929, 738278, 74632, 77032 ]
}
]Đang tải editor...