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

@@ -31,12 +31,13 @@ class Patch
* Query to patch (partially update) a document by its ID
*
* @param string $tableName The name of the table in which a document should be patched
* @param mixed $docId The ID of the document to be patched (optional; string ID assumed)
* @return string The query to patch a document by its 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::update($tableName, Query::whereById());
return self::update($tableName, Query::whereById(docId: $docId));
}
/**
@@ -52,4 +53,28 @@ class Patch
{
return self::update($tableName, Query::whereByFields($field, $match));
}
/**
* Query to patch (partially update) a document via a JSON containment query (PostgreSQL only)
*
* @param string $tableName The name of the table in which documents should be patched
* @return string The query to patch documents via a JSON containment query
* @throws DocumentException If the database mode is not PostgreSQL
*/
public static function byContains(string $tableName): string
{
return self::update($tableName, Query::whereDataContains());
}
/**
* Query to patch (partially update) a document via a JSON Path match query (PostgreSQL only)
*
* @param string $tableName The name of the table in which documents should be patched
* @return string The query to patch documents via a JSON Path match
* @throws DocumentException If the database mode is not PostgreSQL
*/
public static function byJsonPath(string $tableName): string
{
return self::update($tableName, Query::whereJsonPathMatches());
}
}