public function find()
{
$options = [];
if ($filter = $this->param("filter", null)) {
$options["filter"] = $filter;
}
if ($limit = $this->param("limit", null)) {
$options["limit"] = $limit;
}
if ($sort = $this->param("sort", null)) {
$options["sort"] = $sort;
}
if ($skip = $this->param("skip", null)) {
$options["skip"] = $skip;
}
$docs = $this->app->db->find("common/forms", $options);
if (count($docs) && $this->param("extended", false)) {
foreach ($docs as &$doc) {
$doc["count"] = $this->app->module("forms")->collectionById($doc["_id"])->count();
}
}
return json_encode($docs->toArray());
}