         let app = UIApplication.sharedApplication().delegate as! AppDelegate
         let db = app.syncHelper!.database
 
-        db.viewNamed("messages").setMapBlock("2") { (doc, emit) in
+        db.viewNamed("messages").setMapBlock("3") { (doc, emit) in
             if let type = doc["type"] as? String where type == "message" {
                 if let room = doc["room"] as? String,
                     let date = doc["created_at"] as? String,
+                    let username = doc["user"] as? String,
                     let message = doc["message"] as? String {
-                    emit([room, date], message)
+                    emit([room, date], [username, message])
                 }
             }
         }

            return
        }

        let message = text!

        let properties = [
            "type": "message",
            "room": self.chatroomId!,
            "created_at": CBLJSON.JSONObjectWithDate(NSDate()),
            "message": message
        ]



        if let cell = cell,
            let row = liveQuery?.rows?.rowAtIndex(UInt(indexPath.row)),
            let values = row.value as? Array<String> {

                cell.textLabel!.text = values[1]
                cell.detailTextLabel!.text = values[0]
        }

        return cell
