toDB(); DB::table($this->table)->insert($revisionDB); return $revision->id; } /** * @return Collection **/ public function getByRecordId(string $rid): Collection { $revisions = DB::table($this->table) ->where("recordId", $rid) ->get() ->map([Revision::class, 'fromDB']) ->sortByDesc("_sys.version") ->toArray(); return new Collection($revisions); } /** * @return Option */ public function getByRecordIdAndVersion(string $rid, int $version): Option { $res = DB::table($this->table) ->where("recordId", $rid) ->where('_sys->version', $version)->first(); if (empty($res)) { return none(); } return some(Revision::fromDB($res)); } }