MongoDB provides various ways to update a document. The method you use will depend on exactly how you want to perform the update.
This article presents 4 ways to update a document in MongoDB.
Continue readingMongoDB provides various ways to update a document. The method you use will depend on exactly how you want to perform the update.
This article presents 4 ways to update a document in MongoDB.
Continue readingMongoDB has a $push
operator and an $addToSet
operator, both of which do a very similar thing.
Both operators append values to an existing array. The main difference is in how they deal with arrays that already contain the value you’re trying to append, and also in the modifiers that can be used.
Continue readingIf you encounter the “index name must be a string” error when dropping multiple indexes in MongoDB, it’s probably because you’re passing the specifications document instead of the name.
When you use the dropIndexes()
method or the dropIndexes
command to drop multiple indexes, you need to pass the index names (not the specifications documents) in an array.
If you’re wondering what version of MongoDB you’re running, here are 7 ways you can use to check.
Actually, some of these check your MongoDB server version, and some check your mongo shell version. In any case, let’s take a look.
Continue readingThis article presents 5 ways to return the milliseconds portion from a Date object in MongoDB.
Continue readingThis article presents 5 ways to return the seconds portion from a Date object in MongoDB.
Continue readingThis article presents 5 ways to return the minutes portion from a Date object in MongoDB.
Continue readingMongoDB provides a good range of aggregation pipeline operators for working with dates, including operators that extract certain parts of dates, such as the year, month, day, hours, minutes, etc.
There are also a couple of MongoDB methods that enable you to iterate through a cursor, and apply a JavaScript function. You can therefore use JavaScript to extract date values and date parts, etc from a field as required.
This article presents 5 ways to return the hour portion from a Date object in MongoDB.
Continue readingIn MongoDB, you can use the $push
operator to append a value to an array.
This operator can be used with various modifiers, one of which is the $position
modifier. The $position
modifier allows you to specify the position within the array that you want to insert the new value.
MongoDB provides various options for extracting date parts from a date.
This article presents 3 ways to return the week portion from a date in MongoDB.
Continue reading