Sling Academy
Home/MongoDB/MongoDB Tutorials

MongoDB Tutorials

This series of tutorials helps you learn MongoDB from basic to advanced concepts, from simple to complex topics.

1 4 Ways to install MongoDB on Windows

2 3 Ways to install MongoDB on Mac

3 3 ways to self-host MongoDB on Ubuntu

4 How to check version and update MongoDB on Windows

5 How to check version and upgrade MongoDB on Mac

6 Checking version and upgrading MongoDB on Ubuntu

7 An Introduction to NoSQL and MongoDB for Beginners

8 How to completely remove MongoDB from Windows

9 How to completely uninstall MongoDB from Mac

10 How to Completely Remove MongoDB from Ubuntu

11 MongoDB Shell: How to Execute Queries Saved in a File

12 How to view the disk space used by MongoDB

13 How to install MongoDB Shell (mongosh) on Windows, Mac, and Ubuntu

14 Where does MongoDB store data and how to change it

15 What is the Default Port of MongoDB and How to Change It

16 When not to use MongoDB and why?

17 MongoDB: 3 ways to dump/export a database to a JSON or CSV file

18 MongoDB: 3 Ways to Import JSON/CSV Files to Database

19 How to migrate from MySQL to MongoDB

20 3 ways to create a new database in MongoDB

21 How to add comments into MongoDB queries?

22 3 Ways to List All Databases in MongoDB

23 MongoDB Connection String URI Format: Explained with Examples

24 4 Ways to Drop a Database in MongoDB

25 MongoDB: How to determine the size of a database (5 ways)

26 MongoDB: How to create an admin user and enable authentication

27 MongoDB: Managing users and roles (privileges)

28 MongoDB: 3 ways to reset root password on Windows

29 MongoDB: How to reset root password on Mac

30 MongoDB: How to reset root password on Ubuntu

31 MongoDB: 4 ways to view all users and their roles.

32 5 ways to mimic ENUM behavior in MongoDB (with examples)

33 MongoDB Shell: How to Connect to a Remote Server

34 MongoDB Shell: How to select a database to use

35 MongoDB Shell Commands: The Complete Cheat Sheet

36 MongoDB: How to create and query a view

37 MongoDB: How to modify/remove a view (with examples)

38 MongoDB: How to temporarily disable a user

39 MongoDB: How to use a view to join collections (with examples)

40 MongoDB: How to create a view with default collection

41 Understanding Materialized Views in MongoDB (through Examples)

42 Understanding ObjectId data type in MongoDB (with examples)

43 MongoDB Date data type: A practical guide (with examples)

44 MongoDB Int32 and Long data types: A practical guide (with examples)

45 MongoDB Integer & Double data types: A practical guide (with examples)

46 Working with String data type in MongoDB (with examples)

47 Boolean data type in MongoDB: Tutorial & Examples

48 Understanding Min key and Max key in MongoDB (with examples)

49 Array data type in MongoDB: A practical guide (with examples)

50 Object data type in MongoDB: Tutorial & Examples

51 Undefined and Null data types in MongoDB (with examples)

52 Working with Binary data in MongoDB (with examples)

53 MongoDB Timestamp data type: A practical guide (with examples)

54 How to create validation rules in MongoDB (with examples)

55 What is BSON in MongoDB? Explained with examples

56 Understanding MongoDB capped collections (fixed-size collections)

57 MongoDB: 3 ways to view all collections in a database

58 MongoDB: How to create/drop a collection (with examples)

59 MongoDB: How to move a collection to a different database (4 ways)

60 The maximum size of a document in MongoDB

61 MongoDB: Best practices to name collections and fields

62 Is document field order respected in MongoDB?

63 MongoDB: How to use custom primary key (e.g., my_id instead of _id)

64 MongoDB: How to set your own _id field value (with examples)

65 MongoDB: How to insert a new document and get its ID (with examples)

66 MongoDB: Insert multiple documents and get their IDs (with examples)

67 MongoDB db.collection.updateOne() method (with examples)

68 MongoDB db.collection.updateMany() method (with examples)

69 MongoDB: Is there something like ‘NOT NULL’ constraint in SQL?

70 MongoDB: How to add UNIQUE constraint to a field (with examples)

71 MongoDB db.collection.findAndModify() method (with examples)

72 MongoDB db.collection.findOneAndUpdate() method (with examples)

73 MongoDB db.collection.findOneAndReplace() method (with examples)

74 Using db.collection.bulkWrite() method in MongoDB (with examples)

75 How to add index to a field in MongoDB (with examples)

76 Using compound and multikey indexes in MongoDB (with examples)

77 MongoDB full-text index: A practical guide (with examples)

78 MongoDB: How to identify and drop unused indexes (with examples)

79 MongoDB: Viewing usage statistics of all indexes in a collection

80 MongoDB: How to Select All Documents in a Collection

81 MongoDB: How to specify which fields to return in a query (projection)

82 MongoDB: Excluding sensitive fields from query results (with examples)

83 MongoDB: Using $eq and $ne operators to match values (with examples)

84 MongoDB: Using $gt and $gte operators (with examples)

85 Using $lt and $lte operators in MongoDB (with examples)

86 Using $in and $nin operators in MongoDB (with examples)

87 Using $and & $or operators in MongoDB (with examples)

88 MongoDB: Using $not and $nor operators to negate a query

89 MongoDB: Using $where Operator to Query Using JavaScript Expression

90 MongoDB: Performing text search using $text operator (with examples)

91 MongoDB: Using $expr to query using aggregation expressions

92 Using MongoDB $jsonSchema to validate documents (with examples)

93 MongoDB: Using $mod operator to query documents using modulo operation

94 MongoDB: Mimic SQL ‘LIKE’ and ‘NOT LIKE’ operators (with examples)

95 MongoDB: Using limit() and skip() methods for pagination (with examples)

96 MongoDB: Sorting by a single field and multiple fields (with examples)

97 MongoDB: Find documents with null or missing fields (with examples)

98 MongoDB: Find documents between two dates (with examples)

99 MongoDB: Select documents in a period of time (last day, week, month, year)

100 MongoDB: Find documents whoose field value is an array (with examples)

101 MongoDB: Find documents whose field contains a substring (with examples)

102 MongoDB: How to count documents based on a condition (with examples)

103 MongoDB: 3 ways to select a random document from a collection

104 MongoDB: 3 Ways to Select N Random Documents

105 Using $group aggregation stage in MongoDB (with examples)

106 MongoDB: Grouping documents by multiple fields (with examples)

107 MongoDB: Grouping documents by date (day, month, year)

108 A closer look at timezones in MongoDB (with examples)

109 MongoDB Aggregation: MIN, MAX, SUM, AVG, COUNT (with examples)

110 MongoDB: Find SUM/MIN/MAX/AVG of each group in a collection

111 MongoDB Upsert: Update if exists, otherwise insert new record

112 Embedded documents in MongoDB: A practical guide (with examples)

113 MongoDB: How to combine data from 2 collections into one

114 References (Manual Linking) in MongoDB: A Developer’s Guide (with Examples)

115 MongoDB: How to add a comment to a query predicate

116 Understanding cursor-based pagination in MongoDB

117 Geospatial in MongoDB: A practical guide (with examples)

118 MongoDB: using $all operator to match arrays (with examples)

119 MongoDB: Using $elemMatch operator to match elements in an array

120 Matching binary values in MongoDB: A practical guide (with examples)

121 Understanding $slice operator in MongoDB (with examples)

122 MongoDB createdAt and updatedAt fields: A practical guide (with examples)

123 Working with Change Streams in MongoDB (with examples)

124 Understanding Transactions in MongoDB (with examples)

125 Type checking in MongoDB: A practical guide (with examples)

126 MongoDB: Find documents that contain a field (with examples)

127 MongoDB: Set default value for a field (with examples)

128 MongoDB: How to add auto-incrementing field to a collection

129 MongoDB: How to update a nested field (with examples)

130 How to update a nested array in MongoDB

131 MongoDB: Using $dateToString to format date time

132 MongoDB: Using $dateFromString to convert string to date

133 Working with $dateAdd and $dateSubtract in MongoDB (with examples)

134 MongoDB: Using $dateDiff to find difference between dates (with examples)

135 Get the current date and time in MongoDB (with examples)

136 MongoDB: How to rename a field in a document (with examples)

137 MongoDB: How to remove a field in a document

138 MongoDB: 4 ways to safely rename a database

139 MongoDB: How to rename a collection in a database

140 Understanding MongoDB $setOnInsert operator (with examples)

141 Manipulating array fields in MongoDB (with examples)

142 How to set timeout for a MongoDB query

143 MongoDB: How to View Error and Query Logs

144 MongoDB: 4 Ways to Remove Duplicate Documents

145 MongoDB: Using db.runCommand() to execute database commands

146 MongoDB: How to truncate/empty a collection

147 MongoDB: How to see all fields in a collection (with examples)

148 How to truncate a date in MongoDB (reduce precision)

149 How to query an array of subdocuments in MongoDB (with examples)

150 Query on Nested Documents in MongoDB: A Practical Guide

151 MongoDB Snapshot Queries: A Practical Guide (with examples)

152 How to iterate a cursor in mongosh (MongoDB Shell)

153 MongoDB deleteOne() method: A practical guide (with examples)

154 MongoDB deleteMany() method: A developer’s guide (with examples)

155 MongoDB remove() method – Explained with examples

156 MongoDB: How to retry on read/write failure (with examples)

157 MongoDB: How to select distinct values from a collection (with examples)

158 MongoDB: Counting distinct values in each group

159 MongoDB: How to compare 2 documents (with examples)

160 MongoDB: Comparing 2 fields in the same document

161 MongoDB: Using estimateDocumentCount() in Large Collections

162 Exploring MongoDB configuration file (mongod.conf)

163 Caching in MongoDB: A practical guide (with examples)

164 How to define a JavaScript function within MongoDB shell

165 Understanding $floor and $ceil operators in MongoDB (with examples)

166 MongoDB: Checking if a Field is Array Using $isArray Operator

167 MongoDB: Check if a field is number with $isNumber operator

168 MongoDB: Exploring $first, $firstN, $last, and $lastN operators

169 MongoDB: Using $mergeObjects to merge multiple documents into one

170 MongoDB: Make all documents have the same structure by filling missing fields

171 MongoDB: Setting an expiration time for a document (TTL index)

172 Introduction to time series collections in MongoDB (with examples)

173 MongoDB: What happens if two clients update the same document at the same time?

174 How to round and format numbers in MongoDB (with examples)

175 MongoDB: Using $setIntersection to find common elements in arrays

176 MongoDB: Using $setUnion to Combine Multiple Arrays into One

177 MongoDB: How to update a field based on its current value (with examples)

178 MongoDB: How to update a field based on another field’s value

179 MongoDB: How to update multiple array elements matching a condition

180 MongoDB: How to perform JOIN operations using $lookup

181 MongoDB: How to filter array in subdocument

182 MongoDB: Append a value to an array field (with examples)

183 MongoDB: Filter documents based on array length (with examples)

184 MongoDB: Find documents whose array contains a specific value

185 MongoDB: How to concatenate strings in aggregation pipeline (with examples)

186 MongoDB: How to perform case-insensitive search (with examples)

187 MongoDB: How to remove array elements matching a condition

188 MongoDB: Grouping results by multiple fields (with examples)

189 MongoDB: Using $pipeline in $lookup (for Complex Joins)

190 How to perform cascade deletion in MongoDB (with examples)

191 Encoding in MongoDB: A practical guide (with examples)

192 How to prevent injection attacks in MongoDB (with examples)

193 MongoDB: Converting string to number (with examples)

194 How to store images in MongoDB (and why you should not)

195 MongoDB: Sorting Documents by a Field but NULL First/Last

196 How to run MongoDB commands from bash script (with examples)

197 MongoDB: How to replace a substring in a string (with examples)

198 How to clone a collection in MongoDB (but with different name)

199 Self-Referencing Documents in MongoDB: A Practical Guide (with examples)

200 Encryption in MongoDB: A practical guide (with examples)

201 MongoDB: Using Vermongo to track document history (with examples)

202 MongoDB: Sorting Documents by Updated Time

203 When not to use MongoDB? Here’re 7 common scenarios

204 MongoDB: Select/count distinct values in multiple fields

205 Using variables in MongoDB aggregation pipeline (with examples)

206 Define and use variables in MongoDB Shell (mongosh)

207 One-to-One Relations in MongoDB: A Practical Guide

208 One-to-Many Relations in MongoDB: The Ultimate Guide (with examples)

209 Many-to-Many Relations in MongoDB: The Complete Guide (with Examples)

210 MongoDB: How to Change the Validation Action

211 MongoDB: Using lookUp() to merge reference relations

212 MongoDB: Using Projection in Arrays – Tutorial & Examples

213 MongoDB: Using $min, $max, and $mul when updating documents

214 Understanding $addToSet operator in MongoDB (with examples)

215 MongoDB: Calculating the Distance between 2 Locations

216 MongoDB: Find the Nearest Place to a Location

217 MongoDB: Check if a Location is in a Specific Area

218 Weighted Random Selection in MongoDB: A Practical Guide (with examples)

219 Understanding ‘Covered Query’ in MongoDB (with Examples)

220 Partial Index and Partial Filter in MongoDB: A Practical Guide

221 Creating Text Index and Compound Text Index in MongoDB

222 MongoDB $bucket aggregation stage: A practical guide

223 Working with the $unwind stage in MongoDB

224 Using the $geoNear Stage in MongoDB

225 Geospatial Indexes in MongoDB: How to Speed Up Geospatial Queries

226 Partitioning and Sharding in MongoDB: A Practical Guide (with Examples)

227 Hashed Indexes in MongoDB: A Practical Guide

228 Understanding Partial Indexes in MongoDB

229 Exploring Sparse Indexes in MongoDB (with Examples)

230 Using Wildcard Indexes in MongoDB: An In-Depth Guide