 //        objects.insert(NSDate(), atIndex: 0)
 //        let indexPath = NSIndexPath(forRow: 0, inSection: 0)
 //        self.tableView.insertRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
+
+        let newChatroom = database.createDocument()
+        let properties = ["type": "chatroom", "name": "from code"]
+
+        do {
+            try newChatroom.putProperties(properties)
+        } catch {
+            print("Could not create a new room")
+        }
     }
 
     // MARK: - Segues

                controller.navigationItem.leftBarButtonItem = self.splitViewController?.displayModeButtonItem()
                controller.navigationItem.leftItemsSupplementBackButton = true

                if let row = rows?.rowAtIndex(UInt(indexPath.row)),
                    let name = row.key as? String {
                        controller.detailItem = name
                }

    // MARK: - Table View

    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return liveQuery?.rows == nil ? 0 : 1
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

        if let rows = liveQuery?.rows {
            let count = rows.count
            return Int(count)
        }
