Add PostgreSQL Support (#3)
Reviewed-on: #3
This commit was merged in pull request #3.
This commit is contained in:
@@ -13,12 +13,13 @@ class Delete
|
||||
* Query to delete a document by its ID
|
||||
*
|
||||
* @param string $tableName The name of the table from which a document should be deleted
|
||||
* @param mixed $docId The ID of the document to be deleted (optional; string ID assumed)
|
||||
* @return string The DELETE statement to delete 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 "DELETE FROM $tableName WHERE " . Query::whereById();
|
||||
return "DELETE FROM $tableName WHERE " . Query::whereById(docId: $docId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,4 +35,28 @@ class Delete
|
||||
{
|
||||
return "DELETE FROM $tableName WHERE " . Query::whereByFields($fields, $match);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query to delete documents using a JSON containment query (PostgreSQL only)
|
||||
*
|
||||
* @param string $tableName The name of the table from which documents should be deleted
|
||||
* @return string The DELETE statement to delete documents via a JSON containment query
|
||||
* @throws DocumentException If the database mode is not PostgreSQL
|
||||
*/
|
||||
public static function byContains(string $tableName): string
|
||||
{
|
||||
return "DELETE FROM $tableName WHERE " . Query::whereDataContains();
|
||||
}
|
||||
|
||||
/**
|
||||
* Query to delete documents using a JSON Path match query (PostgreSQL only)
|
||||
*
|
||||
* @param string $tableName The name of the table from which documents should be deleted
|
||||
* @return string The DELETE statement to delete documents via a JSON Path match
|
||||
* @throws DocumentException If the database mode is not PostgreSQL
|
||||
*/
|
||||
public static function byJsonPath(string $tableName): string
|
||||
{
|
||||
return "DELETE FROM $tableName WHERE " . Query::whereJsonPathMatches();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user