Start a new topic

What is the best way to detect if a save operation os a first time save or an update?

Is it possible using collection hooks?



tks
1 Comment

There is no clear-cut way to do it, but one possible solution would be to use a pre-save hook to query for the _id value that is passed in the request. If the request action is PUT, and if it is a POST that doesn't include an _id, one can assume that it is a first-time save. If the request is a POST with an included _id, then the only way to determine if it is a first-time save or second-time save is to query the collection for the passed _id.
Login or Signup to post a comment