You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/40-using-arrays/10-types-of-arrays.mdx
+43-1
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ import TabItem from '@theme/TabItem';
3
3
4
4
# 👐 Types of arrays
5
5
6
-
A JSON array can contain __scalar values__ or __objects__. In our data, `books` have a scalar array of the `genres` this book belongs to. It also has several arrays of objects, like the `authors` of a book, `attributes` and `reviews`.
6
+
A JSON array can contain __simple values__ (scalar values) or __objects__. In our data, `books` have a scalar array of the `genres` this book belongs to. It also has several arrays of objects, like the `authors` of a book, `attributes` and `reviews`.
7
7
8
8
Let's get one book:
9
9
@@ -110,3 +110,45 @@ I got this one. (It can change depending on the data source you imported.)
## 👐 Find all the books that belong only to the genres "Fiction" and "Science Fiction"
110
+
111
+
In this case, we want books that have both "Fiction" and "Science Fiction" in the genres array _and nothing else_. So we're looking for documents that contain a `genres` array exactly as `['Fiction', 'Science Fiction']`. We're not looking for the individual genres that could be inside the array, instead we are comparing the whole array on each document.
83
112
84
113
<TabsgroupId="aggregations">
85
114
<TabItemvalue="atlas"label="Atlas UI">
86
115
87
116
```js
88
117
[
89
-
{
90
-
$match: {
91
-
genres: ['Science Fiction', 'Fiction']
118
+
{$match: {
119
+
genres: ['Fiction', 'Science Fiction']
92
120
}
93
121
},
94
122
{$project: {
@@ -103,9 +131,8 @@ Here we're comparing the whole array. __Elements order is important__. With this
0 commit comments