Database model - gronnbeck/webirc GitHub Wiki

Introduction

This document describes the database model of logapi (and some design rationale).

Definitions

User: User of IRC

Connection: Is a connection setup by the user and an IRC server. This connection is not meant to be persistent, and ends when the user closes it.

Session: Is a persistent connection between the user and the IRC server. That means there exists some form of mechanism keeping the users connection to the IRC server alive when the user closes it.

The Model

For each user we want to persist data/logs from each session. Each session can save logs from all channels and private messages. WebIRC should structure logs from every channel/pm as unique documents.

Document ID

CouchDB forces each document to have a globally unique ID. Thus, we introduce the following scheme for generating document IDs. Let session_id be a unique generated hash such as SHA1 or SHA256 which should be unique for every session.

<session_id>_[chan/pm]_<channel/nick>

That is, an ID should consist of an unique session id followed by an type of log identifier. To be able to discriminate between channels we add the message channel name at the end of the identifier. Same goes for private messages.

The two IDs below are logs related to session 428531... talking in the channel #magrathea and the private conversation between me and Marvin (the bot).

4285317a3fc8ee0e4cd6611cf8fa9e4c_chan_magrathea
4285317a3fc8ee0e4cd6611cf8fa9e4c_pm_marvin
⚠️ **GitHub.com Fallback** ⚠️