Model user specific properties

Hello,

What are the best practices for user preferences on a specific object?
For example: Modeling a chatroom entity.
The chatroom have some components, a creation date, a name.
Now I would add a new feature: the chatroom could be “pinned at top”.
So essentially the pinned chat always show up on the top of the list.

An easy way to manage it is to add a “pinned” property, which is a list of user names that pinned that specific chat.
But here I see a privacy problem, because this let all users to see who pinned the chat.
Sure, it isn’t a great problem in this case, but could it be in others.

An other way to model it could it be create another document, “chat_preferences”, that contain user specific preferences, accessible only from the corresponding user.
But in that case I can’t see how could the mobile application show the list of chatrooms ordered by pinned.
It could be easy to done if N1QL would be available (with a join), but on mobile is not (at least until 2.0 will become in production).
So how could I do? Query for “chat_preferences” instead of chats?

I agree, it’s a bad idea to put per-user prefs in a shared chat document. Besides the privacy issues it can also lead to conflicts if multiple users change prefs at roughly the same time.

But in that case I can’t see how could the mobile application show the list of chatrooms ordered by pinned.

You don’t have to do everything with a single query. Read the doc that lists the pinned chat rooms, then sort the chat rooms yourself by consulting the list of pinned ones. There aren’t going to be so many chat rooms in the list that this takes a long time to sort.