Hello,
I am trying to implement the mention feature (@mention) for my app. However, I am not entirely sure how I should design the documents for this feature.
The first way I could think of is to have a placeholder code (something like [&] for example) to specify the place where mentions happens, and have a ‘mentions’ field containing the userID of the mentioned users (this field could either be an array of string or a map[string]int mapping the id with the corresponding position of the mentions). Front end could then replace the placeholder code with the mention text (@FirstName LastName for example) and display when it receives the document from back end.
A message document containing ‘Hey @A, @B’ would look like this in this case:
messageID: { docType: 'message', text: 'Hey [&], [&]', mentions: ['uid::a', 'uid::b'], }
or
messageID: { docType: 'message', text: 'Hey [&], [&]', mentions:{ 'uid:a': 1, 'uid:b': 2 }, }
The second way could be having some kind of format like [@username]{user::id} or @{user::id} to specify that that the person with userID of user::id is being tagged at that position of the text (kinda similar to how markdown does hyperlink I think). Then front end could format it correspondingly to display the tagging.
In this case , the same message above would be stored as below:
messageID: { docType: 'message', text: 'Hey [@A]{uid::a}, [@B]{uid::b}', }
or
messageID: { docType: 'message', text: 'Hey @{uid::a}, @{uid::b}', }
This is probably less about Couchbase db specifically and more about designing the db in general, but I am pretty inexperienced and do not know what is the better way to implement this (or if there is another way that is better than the ones I have and solves their issues). Thank you a lot in advance and I would really appreciate any advice or suggestion.