MongoDB
MongoDB With Spring Dataโ
- Both the
@Query
and@Aggregation
annotations can be used to build queries, but the@Aggregation
one provides access to more logic, such as limits and offsets (skip) (source, StackOverflow). - Alternatively for pagination, a
Pageable
argument can be supplied.
Useful Commandsโ
- Set a value to null (requires MongoDB >=4.2 for the
aggregration pipeline)
db.collection.findOneAndUpdate({ _id: ObjectId("foo") }, [
{ $addFields: { deletedDate: null } },
]);
Useful Linksโ
- Query and Projection Operators
- I can never remember the various operators available when writing queries; hereโs the official reference.