Notifications List by UserId

I’m sharing the notification listing function for Lua on the server.

  1. Versions: Nakama {3.23}
  2. Server Framework Runtime language {Lua}
local function GetUserNotifications(user_id, limit, offset)
    local query = [[
      SELECT id, subject, content, code, sender_id, create_time 
      FROM notification 
      WHERE user_id = $1 
      ORDER BY create_time DESC
      LIMIT $2 OFFSET $3;
    ]]

    local notifications = nk.sql_query(query, {user_id, limit, offset})
    return notifications
end

I could not find the notification listing function with the user_id parameter. I have written it by myself. So people can see this topic from Google search :smiley:

I hope this code helps people like me. Have a nice day everyone :wave:

1 Like