/** * Delete Collection and all its documents * * @param String $name * @param Request $request * @return Response */ public function deleteCollection($name, Request $request) { if (!$this->appKeyAvailable($request)) { return $this->notAuthorized($request); } $collection = $this->readCollection($name); if (!$this->setSessionUser($request)) { $this->setResultError("Not logged in", 401); } elseif (!$this->isAdmin()) { $this->setResultError("Unauthorized action", 403); } elseif (!$collection) { $this->setResultError("Collection name does not exist", 404); } else { Collection::destroy($collection->id); $this->setResultOk(); } return $this->setResponse(); }