 
     override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
         if editingStyle == .Delete {
-//            objects.removeAtIndex(indexPath.row)
-//            tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
+
+            if let row = liveQuery?.rows?.rowAtIndex(UInt(indexPath.row)) {
+                let doc = row.document
+
+                do {
+                    try doc?.deleteDocument()
+                } catch {
+                    print("Could not delete")
+                }
+            }
+
         } else if editingStyle == .Insert {
             // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
         }

        super.viewWillAppear(animated)
    }

    func insertNewObject(sender: AnyObject) {
//        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"]


        let live = query.asLiveQuery()
        live.descending = true

        live.addObserver(self, forKeyPath: "rows", options: [], context: nil)

        liveQuery = live
    }

    override func viewWillAppear(animated: Bool) {
