Where is the chat messages stored?


  • Where are the chat messages between users stored in the database?

  • NodeBB

    They are stored in rooms, and each user has their own list of message ids. So if you have the roomId and a uid then you can get the list of message ids from the sorted set 'uid:' + uid + ':chat:room:' + roomId + ':mids' This sorted set contains message ids, to get the actual message data you need to load them from message:<mid>.


  • I'm currently using db.objects.find({_key: /^message:\d+$/}, {content: true})
    How can I also get the username of the sender and receiver, @baris

  • NodeBB

    @whimpers If you get the entire message object it should have a fromuid field, using that id you can get the user object at user:<uid> everyone in the room receives the message, you can get the users in the room from chat:room:<roomId>:uids

Suggested Topics

| |