0

I am trying to store user preference for notifications.

One way to do is store types of notification in separate collection and store UUID of that notification type in user table.

e.g. notification-type

{
  UUID: 'a81ef539-290b-4f28-b364-548970307a66'
  name: 'newuser',
  title: 'new user joined your project.'
}

and then in user collection I store it as following.

user

{
  UUID: '26abfe2b-5da6-4bf2-9419-bb4336173b5a'
  name: 'user1',
  notification-preference: ['a81ef539-290b-4f28-b364-548970307a66']
}

Or alternatively I store directly name of notification type as following and I don't take UUID at all in notification-type collection. This approach requires change in future if I have to change the name though.

{
  UUID: '26abfe2b-5da6-4bf2-9419-bb4336173b5a'
  name: 'user1',
  notification-preference: ['newuser']
}

What is better way to do this?

1 Answer 1

1

Using the plain names is more like a fallback when UUID is not possible. UUID is unique and bound to the data itself, while name adds an indirect layer: use_site -> name -> data.

Since you are mainly storing it in a database, I suppose it is better to use UUID.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.