private function connect()
 {
     if (!isset(self::$collection)) {
         self::$connection = new MongoClient(self::MONGO_HOST);
         $db = self::$connection->selectDb(self::DATABASE_NAME);
         self::$collection = $db->selectCollection(self::COLLECTION_NAME);
         self::$collection->createIndex(array('name' => 1), array('unique' => 1, 'dropDups' => 1));
     }
     return true;
 }
function deleteCategoryById($id)
{
    $app = \Slim\Slim::getInstance();
    try {
        $app->response->write(json_encode(CategoriesDAO::delete($id)));
        return json_encode($app->response->getBody());
    } catch (Exception $e) {
        $app->response->setStatus(404);
        $app->response->setBody(getErrorMessage($e));
        return json_encode($app->response->getBody());
    }
}