Skip to main content


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 } },