When using mongoimport
, you can use the --jsonArray
parameter to import an array of JSON documents.
Category: DBMS
Database Management Systems
Find Out if a Query uses an Index in MongoDB
In MongoDB, you can use the cursor.explain()
method or the db.collection.explain()
method to determine whether or not a query uses an index.
These methods enable you to view the query plan for the query, which includes whether or not it uses an index.
Continue readingMongoDB $sample
In MongoDB, the $sample
aggregation pipeline stage randomly selects the specified number of documents from its input.
MongoDB $rand
In MongoDB, the $rand
aggregation pipeline operator returns a random float between 0 and 1.
The floating point value has up to 17 digits after the decimal point. Any trailing zeros are dropped, so the number of digits may vary.
The $rand
operator was introduced in MongoDB 4.4.2.
How to Fix “The configuration option ‘Agent XPs’ does not exist” in SQL Server (T-SQL)
If you encounter error Msg 15123, Level 16, reading “The configuration option ‘Agent XPs’ does not exist“, you were probably trying to execute EXEC SP_CONFIGURE 'Agent XPs'
while advanced options are hidden.
This error is easily fixed.
Continue readingMongoDB $nin Query Operator
In MongoDB, the $nin
query operator selects the documents where the field’s value is not in the specified array or where the field doesn’t exist.
MongoDB $ne Aggregation Pipeline Operator
In MongoDB, the $ne
aggregation pipeline operator compares two values and returns either true
or false
, depending on whether the two values are not equivalent.
MongoDB $in Aggregation Pipeline Operator
In MongoDB, the $in
aggregation pipeline operator returns a boolean indicating whether a specified value is in the array.
The $in
aggregation pipeline operator is not to be confused with the $in
query operator, which selects the documents where the value of a field equals any value in the specified array.
MongoDB $in Query Operator
In MongoDB, the $in
query operator selects the documents where the value of a field equals any value in the specified array.
The $in
query operator is not to be confused with the $in
aggregation pipeline operator, which returns a boolean indicating whether a specified value is in the array.
2 Ways to Delete a Database in MongoDB
If you no longer need a database in MongoDB you can delete it.
Technically speaking, the term normally used for deleting a database is drop. To drop a database is to delete it.
In any case, below are two ways you can drop/delete a database in the mongo shell.
Continue reading