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

@@ -25,12 +25,13 @@ class Exists
* Query to determine if a document exists for the given ID
*
* @param string $tableName The name of the table in which document existence should be checked
* @param mixed $docId The ID of the document whose existence should be checked (optional; string ID assumed)
* @return string The query to determine document existence by ID
* @throws DocumentException If the database mode has not been set
*/
public static function byId(string $tableName): string
public static function byId(string $tableName, mixed $docId = null): string
{
return self::query($tableName, Query::whereById());
return self::query($tableName, Query::whereById(docId: $docId));
}
/**
@@ -46,4 +47,28 @@ class Exists
{
return self::query($tableName, Query::whereByFields($fields, $match));
}
/**
* Query to determine if documents exist using a JSON containment query (PostgreSQL only)
*
* @param string $tableName The name of the table in which document existence should be checked
* @return string The query to determine document existence by a JSON containment query
* @throws DocumentException If the database mode is not PostgreSQL
*/
public static function byContains(string $tableName): string
{
return self::query($tableName, Query::whereDataContains());
}
/**
* Query to determine if documents exist using a JSON Path match query (PostgreSQL only)
*
* @param string $tableName The name of the table in which document existence should be checked
* @return string The query to determine document existence by a JSON Path match
* @throws DocumentException If the database mode is not PostgreSQL
*/
public static function byJsonPath(string $tableName): string
{
return self::query($tableName, Query::whereJsonPathMatches());
}
}