I am creating a notification system within my app which displays notifications in a drop down, similar to what you would see in Facebook.
In my database, I have set up an entity type ‘Notification’ which has a ‘read?: Yes/ No’ value.
Under each user, they can have a list of notifications.
I am having trouble changing the ‘read: Yes/No’ value on the list of notifications associated to each user.
My work flow is set up per below, however when I trigger this workflow, the notification in the database doesn’t change the ‘Read?’ value to ‘yes’.
Furthermore, I have an icon displaying the number of ‘unread=No notifications’ and even when I manually update the list of notifications to ‘Read?=yes’ it still displays the same number of notifications regardless of the yes/no value in my database.
Does anyone have any suggestions as to where I am going wrong?
There are a bunch of different ways to do this type of thing.
Just one way I am thinking about is to have a list of users attached to the notification, if the user views the notification, then add the user to the ‘usersWhoViewed’ list.
Or another option: once the user views a notification, then add it to the user’s ‘notificationViewed’ list.
If you do a ‘yes/no’ field attached to a notification, depending on how you have your database, it might be turning it ‘yes/no’ for all users.
Thanks, yes I had considered a few different ways of setting this up, one other option as you suggested changing to to a different type i.e. user notification ‘viewed’ list. However, my understanding is that this is how a boolean in Bubble should work or perhaps I am missing something?
I don’t want to add anything additional to my database if it’s unnecessary. There are only two users as an attribute to the type ‘notification’ which is a creator and the recipient.
Not sure, but my guess is it has something to do with the expression having to do multiple searches… current user, their list of notifications, and then the yes/no field which is a different datatype than the user.
Try using a “:filter” to narrow the list of notifications to yes/no, and then put the :count at the end of that.
So… “Current User’s List of unread Notifications:filtered:count”
And within the :filtered search box, you put Read? = “yes”
Great! I think the issue is that you are effectively doing a search based on yes/no, and that search needed to either be in the search panel, or via a filter search, rather than just sitting within an expression.
Separately, when looking at your data structure (having a list of notifications within the user field), this discussion came to mind: Alternative approach to the Bubble’s recent tutorials for list of things You may have already seen it, but it gets into pros/cons of having longer lists within a datatype.
Thanks again, I hadn’t seen that thread but glad you pinned it as Im trying to ensure I build my database the right way from the beginning so that’s essential reading.