how to set security rules to prevent updating of data by other users in firebase

I am new in firebase I want to know how to set security rules to prevent updating of data by other users in firebase. I working on a blog app where user can login and write their blogs and I want to prevent the user to do not update or delete another users blog.

Answer

It will depend on the structure of your app. You can also create a function inside the firestore rules, here’s one example:

match /blog/{blogId} {
   allow update, delete: if isBlogOwner();
   function isBlogOwner() {
      return request.auth.uid == resource.data.author;
   }
}

It allows to update or delete a blog if he / she is the blog owner. If you want to know more visit this documentation.