MongoDB Aggregation Pipeline and Pagination

One of the most common problems in web development is paginating a set of data. It’s common that the set of data we need to show our users is pretty big and we might want to show only a part of it retrieving the next slices only when requested. Skip/Limit Pagination The most common way to achieve this is usually to count the number of items and split them in pages, each of a fixed set of items. This is usually achieved through the limit, skip and count operators. For the purpose of this post I’ll be relying on a collection containing tickets for a project management tool, each document looks like: {u’_id': ObjectId(‘4eca327260fc00346500000f’), u’_sprint': ObjectId(‘4eca318460fc00346500000b’), u’complexity': u’days’, u’description': u’This […]

MongoDB and UnitOfWork love or hate?

One of the most common source of issues for MongoDB newcomers is the lack of transactions, people have been used to work with transactions for the past 10 years and probably their web frameworks automatically starts, commits and rolls back transactions for them whenever something wrong happens. So we are pretty used to web development environments where the problem of writing only a part of our changes is usually solved out of the box. When people first approach MongoDB I noticed that this behaviour is often took for granted and messed up data might arise from code that crashes while creating or updating entities on the database. No transaction, no party? To showcase the issue, I’ll try to came up […]