{ "_id" : 1, "item" : "abc1", description: "product 1", qty: 300 } |
{ "_id" : 2, "item" : "abc2", description: "product 2", qty: 200 } |
{ "_id" : 3, "item" : "xyz1", description: "product 3", qty: 250 } |
{ "_id" : 4, "item" : "VWZ1", description: "product 4", qty: 300 } |
{ "_id" : 5, "item" : "VWZ2", description: "product 5", qty: 180 } |
7Comparing hai giá trị và trả về:Compares
two values and returns:
true
khi giá trị đầu tiên lớn hơn hoặc tương đương với giá trị thứ hai.
{ "_id" : 1, "item" : "abc1", description: "product 1", qty: 300 } |
{ "_id" : 2, "item" : "abc2", description: "product 2", qty: 200 } |
{ "_id" : 3, "item" : "xyz1", description: "product 3", qty: 250 } |
{ "_id" : 4, "item" : "VWZ1", description: "product 4", qty: 300 } |
{ "_id" : 5, "item" : "VWZ2", description: "product 5", qty: 180 } |
0 Khi giá trị thứ nhất nhỏ hơn giá trị thứ hai.
{ "_id" : 1, "item" : "abc1", description: "product 1", qty: 300 } |
{ "_id" : 2, "item" : "abc2", description: "product 2", qty: 200 } |
{ "_id" : 3, "item" : "xyz1", description: "product 3", qty: 250 } |
{ "_id" : 4, "item" : "VWZ1", description: "product 4", qty: 300 } |
{ "_id" : 5, "item" : "VWZ2", description: "product 5", qty: 180 } |
7 so sánh cả giá trị và loại, sử dụng thứ tự so sánh BSON được chỉ định cho các giá trị của các loại khác nhau.{ "_id" : 1, "item" : "abc1", description: "product 1", qty: 300 } |
{ "_id" : 2, "item" : "abc2", description: "product 2", qty: 200 } |
{ "_id" : 3, "item" : "xyz1", description: "product 3", qty: 250 } |
{ "_id" : 4, "item" : "VWZ1", description: "product 4", qty: 300 } |
{ "_id" : 5, "item" : "VWZ2", description: "product 5", qty: 180 } |
7 compares both value and type, using the
specified BSON comparison order for values of different types.{ "_id" : 1, "item" : "abc1", description: "product 1", qty: 300 } |
{ "_id" : 2, "item" : "abc2", description: "product 2", qty: 200 } |
{ "_id" : 3, "item" : "xyz1", description: "product 3", qty: 250 } |
{ "_id" : 4, "item" : "VWZ1", description: "product 4", qty: 300 } |
{ "_id" : 5, "item" : "VWZ2", description: "product 5", qty: 180 } |
7 có cú pháp sau: has the following syntax:
{ $gte: [ , ] }
Để biết thêm thông tin về biểu thức, xem biểu thức.
Xem xét bộ sưu tập
{ "_id" : 1, "item" : "abc1", description: "product 1", qty: 300 } |
{ "_id" : 2, "item" : "abc2", description: "product 2", qty: 200 } |
{ "_id" : 3, "item" : "xyz1", description: "product 3", qty: 250 } |
{ "_id" : 4, "item" : "VWZ1", description: "product 4", qty: 300 } |
{ "_id" : 5, "item" : "VWZ2", description: "product 5", qty: 180 } |
3 với các tài liệu sau:{ "_id" : 1, "item" : "abc1", description: "product 1", qty: 300 } |
{ "_id" : 2, "item" : "abc2", description: "product 2", qty: 200 } |
{ "_id" : 3, "item" : "xyz1", description: "product 3", qty: 250 } |
{ "_id" : 4, "item" : "VWZ1", description: "product 4", qty: 300 } |
{ "_id" : 5, "item" : "VWZ2", description: "product 5", qty: 180 } |
Hoạt động sau sử dụng toán tử
{ "_id" : 1, "item" : "abc1", description: "product 1", qty: 300 } |
{ "_id" : 2, "item" : "abc2", description: "product 2", qty: 200 } |
{ "_id" : 3, "item" : "xyz1", description: "product 3", qty: 250 } |
{ "_id" : 4, "item" : "VWZ1", description: "product 4", qty: 300 } |
{ "_id" : 5, "item" : "VWZ2", description: "product 5", qty: 180 } |
7 để xác định xem { "_id" : 1, "item" : "abc1", description: "product 1", qty: 300 } |
{ "_id" : 2, "item" : "abc2", description: "product 2", qty: 200 } |
{ "_id" : 3, "item" : "xyz1", description: "product 3", qty: 250 } |
{ "_id" : 4, "item" : "VWZ1", description: "product 4", qty: 300 } |
{ "_id" : 5, "item" : "VWZ2", description: "product 5", qty: 180 } |
5 có lớn hơn hay bằng { "_id" : 1, "item" : "abc1", description: "product 1", qty: 300 } |
{ "_id" : 2, "item" : "abc2", description: "product 2", qty: 200 } |
{ "_id" : 3, "item" : "xyz1", description: "product 3", qty: 250 } |
{ "_id" : 4, "item" : "VWZ1", description: "product 4", qty: 300 } |
{ "_id" : 5, "item" : "VWZ2", description: "product 5", qty: 180 } |
6:{ "_id" : 1, "item" : "abc1", description: "product 1", qty: 300 } |
{ "_id" : 2, "item" : "abc2", description: "product 2", qty: 200 } |
{ "_id" : 3, "item" : "xyz1", description: "product 3", qty: 250 } |
{ "_id" : 4, "item" : "VWZ1", description: "product 4", qty: 300 } |
{ "_id" : 5, "item" : "VWZ2", description: "product 5", qty: 180 } |
7 operator to determine if { "_id" : 1, "item" : "abc1", description: "product 1", qty: 300 } |
{ "_id" : 2, "item" : "abc2", description: "product 2", qty: 200 } |
{ "_id" : 3, "item" : "xyz1", description: "product 3", qty: 250 } |
{ "_id" : 4, "item" : "VWZ1", description: "product 4", qty: 300 } |
{ "_id" : 5, "item" : "VWZ2", description: "product 5", qty: 180 } |
5 is greater
than or equal to { "_id" : 1, "item" : "abc1", description: "product 1", qty: 300 } |
{ "_id" : 2, "item" : "abc2", description: "product 2", qty: 200 } |
{ "_id" : 3, "item" : "xyz1", description: "product 3", qty: 250 } |
{ "_id" : 4, "item" : "VWZ1", description: "product 4", qty: 300 } |
{ "_id" : 5, "item" : "VWZ2", description: "product 5", qty: 180 } |
6:db.inventory.aggregate[ |
[ |
{ |
$project: |
{ |
item: 1, |
qty: 1, |
qtyGte250: { $gte: [ "$qty", 250 ] }, |
_id: 0 |
} |
} |
] |
] |
Hoạt động trả về các kết quả sau:
{ "item" : "abc1", "qty" : 300, "qtyGte250" : true } |
{ "item" : "abc2", "qty" : 200, "qtyGte250" : false } |
{ "item" : "xyz1", "qty" : 250, "qtyGte250" : true } |
{ "item" : "VWZ1", "qty" : 300, "qtyGte250" : true } |
{ "item" : "VWZ2", "qty" : 180, "qtyGte250" : false } |