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
Indexes support the efficient execution of queries in MongoDB. Without indexes, MongoDB must perform a collection scan, i.e. scan every document in a collection, to select those documents that match the query statement. If an appropriate index exists for a query, MongoDB can use the index to limit the number of documents it must inspect.
@@ -866,100 +859,6 @@ MongoDB transactions can exist only for relatively short time periods. By defau
866
859
<b><a href="#">↥ back to top</a></b>
867
860
</div>
868
861
869
-
## Q. ***How to combine data from multiple collections into one collection?***
870
-
871
-
**$lookup**
872
-
873
-
Performs a left outer join to an unsharded collection in the same database to filter in documents from the “joined” collection for processing. To each input document, the `$lookup` stage adds a new array field whose elements are the matching documents from the “joined” collection. The `$lookup` stage passes these reshaped documents to the next stage.
874
-
875
-
**Syntax**
876
-
877
-
```js
878
-
{
879
-
$lookup:
880
-
{
881
-
from:<collection to join>,
882
-
localField:<field from the input documents>,
883
-
foreignField:<field from the documents of the "from" collection>,
884
-
as:<output array field>
885
-
}
886
-
}
887
-
```
888
-
889
-
<div align="right">
890
-
<b><a href="#">↥ back to top</a></b>
891
-
</div>
892
-
893
-
## Q. ***Find objects between two dates MongoDB?***
894
-
895
-
Operator `$gte` and `$lt` is used to find objects between two dates in MongoDB.
## Q. ***Should I normalize my data before storing it in MongoDB?***
964
863
965
864
Data used by multiple documents can either be embedded (denormalized) or referenced (normalized). Normalization, which is increasing the complexity of the schema by splitting tables into multiple smaller ones to reduce the data redundancy( 1NF, 2NF, 3NF).
@@ -1180,16 +1079,6 @@ If you are running a 64-bit build of MongoDB, there is virtually no limit to sto
1180
1079
<b><a href="#">↥ back to top</a></b>
1181
1080
</div>
1182
1081
1183
-
## Q. ***Mention the command to check whether you are on the master server or not?***
1184
-
1185
-
```js
1186
-
db.isMaster()
1187
-
```
1188
-
1189
-
<div align="right">
1190
-
<b><a href="#">↥ back to top</a></b>
1191
-
</div>
1192
-
1193
1082
## Q. ***Can one MongoDB operation lock more than one database?***
1194
1083
1195
1084
Yes. Operations like `db.copyDatabase()`, `db.repairDatabase()`, etc. can lock more than one databases involved.
@@ -1528,86 +1417,6 @@ MongoDB compresses the files by:
1528
1417
<b><a href="#">↥ back to top</a></b>
1529
1418
</div>
1530
1419
1531
-
## Q. ***Is it possible to update MongoDB field using value of another field?***
1532
-
1533
-
The aggregate function can be used to update MongoDB field using the value of another field.
To query if the array field contains at least one element with the specified value, use the filter { `<field>`: `<value>` } where `<value>` is the element value.
1577
-
1578
-
```js
1579
-
db.inventory.find( { tags:"red" } )
1580
-
```
1581
-
1582
-
<div align="right">
1583
-
<b><a href="#">↥ back to top</a></b>
1584
-
</div>
1585
-
1586
-
## Q. ***How to find MongoDB records where array field is not empty?***
Relationships in MongoDB are used to specify how one or more documents are related to each other. In MongoDB, the relationships can be modelled either by Embedded way or by using the Reference approach. These relationships can be of the following forms:
@@ -1738,31 +1547,6 @@ Capped collections restrict updates to the documents if the update results in in
1738
1547
<b><a href="#">↥ back to top</a></b>
1739
1548
</div>
1740
1549
1741
-
## Q. ***How to remove a field completely from a MongoDB document?***
1742
-
1743
-
How do I remove words completely from all the documents in this collection?
0 commit comments