Reputation: 976
i've a notification list, i would like update their status as read
Notification struct :
type Notification struct {
Id string `gorethink:"id,omitempty"`
UserId string
Content string
Read bool
CreatedAt time.Time
}
in my handle function to get notification i put something like this :
func getLastNotifications(w http.ResponseWriter, r *http.Request){
ret := notification.getLastNotification()
userId := getCurrentUserId()
go func(){
r.Table("Notifications").Filter(r.Row.Field("UserId").Eq(userId)).Update(func(term r.Term) r.Term{
//And here i would like only update each Notification with {Read: true}
})
}()
RenderJSON(http.StatusOK, ret)
}
As explained in the code I will wish to update Read to true in each Notification belonging to the user.
So how can i do that ? Thanks
Upvotes: 0
Views: 45
Reputation: 614
You should be able to use the following query to update all of a users posts to read:
r.Table("Notifications").Filter(r.Row.Field("UserId").Eq(userId)).Update(map[string]interface{}{"read": false})
I hope this helps!
Upvotes: 1