Collections\Controller\Api::restoreVersion PHP Method

restoreVersion() public method

public restoreVersion ( )
    public function restoreVersion()
    {
        $versionId = $this->param("versionId", false);
        $docId = $this->param("docId", false);
        $colId = $this->param("colId", false);
        if ($versionId && $docId && $colId) {
            if ($versiondata = $this->app->helper("versions")->get("coentry:{$colId}-{$docId}", $versionId)) {
                $col = "collection" . $colId;
                if ($entry = $this->app->db->findOne("collections/{$col}", ["_id" => $docId])) {
                    $this->app->db->save("collections/{$col}", $versiondata["data"]);
                    return '{"success":true}';
                }
            }
        }
        return false;
    }