Add PostgreSQL Support (#3)

Reviewed-on: #3
This commit was merged in pull request #3.
This commit is contained in:
2024-06-21 13:46:41 +00:00
parent 330e272187
commit 124426fa12
61 changed files with 2290 additions and 223 deletions

View File

@@ -36,4 +36,31 @@ class Count
return Custom::scalar(Query\Count::byFields($tableName, $namedFields, $match),
Parameters::addFields($namedFields, []), new CountMapper());
}
/**
* Count matching documents using a JSON containment query (`@>`; PostgreSQL only)
*
* @param string $tableName The name of the table in which documents should be counted
* @param array|object $criteria The criteria for the JSON containment query
* @return int The number of documents matching the JSON containment query
* @throws DocumentException If the database mode is not PostgreSQL, or if an error occurs
*/
public static function byContains(string $tableName, array|object $criteria): int
{
return Custom::scalar(Query\Count::byContains($tableName), Parameters::json(':criteria', $criteria),
new CountMapper());
}
/**
* Count matching documents using a JSON Path match query (`@?`; PostgreSQL only)
*
* @param string $tableName The name of the table in which documents should be counted
* @param string $path The JSON Path match string
* @return int The number of documents matching the given JSON Path criteria
* @throws DocumentException If the database mode is not PostgreSQL, or if an error occurs
*/
public static function byJsonPath(string $tableName, string $path): int
{
return Custom::scalar(Query\Count::byJsonPath($tableName), [':path' => $path], new CountMapper());
}
}