Best Practise: Meteor Update Methods

Hi,

I was wondering if there is a best practise for handling MongoDB Updates in Meteor methods.

I had initially written 3 Methods (insert, update, remove). I recently created a few specific update Methods that involved other functionality aside from simply updating the database.

I was wondering if I should be doing specific Methods for everything, rather than having a generic update Method? Is there a best practise for this? Do you use both - create a generic update Method for common use and then create specific Methods for functionality that requires a bit of extra work before updating the database?

2 Likes

From experience, we normally start with a simple update function. Then the requirements for update will grow. And then comes a point that the current update is no longer compatible with new requirements. We just refactor in that case to separate the function and retain a main function for “generic” logic applicable for both.

Most cases, generic insert, update, and remove work. We just update and then refactor later as needed

2 Likes