Add PostgreSQL Support (#3)
Reviewed-on: #3
This commit was merged in pull request #3.
This commit is contained in:
@@ -18,7 +18,7 @@ class RemoveFields
|
||||
public static function byId(string $tableName, mixed $docId, array $fieldNames): void
|
||||
{
|
||||
$nameParams = Parameters::fieldNames(':name', $fieldNames);
|
||||
Custom::nonQuery(Query\RemoveFields::byId($tableName, $nameParams),
|
||||
Custom::nonQuery(Query\RemoveFields::byId($tableName, $nameParams, $docId),
|
||||
array_merge(Parameters::id($docId), $nameParams));
|
||||
}
|
||||
|
||||
@@ -39,4 +39,34 @@ class RemoveFields
|
||||
Custom::nonQuery(Query\RemoveFields::byFields($tableName, $namedFields, $nameParams, $match),
|
||||
Parameters::addFields($namedFields, $nameParams));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove fields from documents via a JSON containment query (`@>`; PostgreSQL only)
|
||||
*
|
||||
* @param string $tableName The table in which documents should have fields removed
|
||||
* @param array|object $criteria The JSON containment query values
|
||||
* @param array|string[] $fieldNames The names of the fields to be removed
|
||||
* @throws DocumentException If the database mode is not PostgreSQL, or if an error occurs
|
||||
*/
|
||||
public static function byContains(string $tableName, array|object $criteria, array $fieldNames): void
|
||||
{
|
||||
$nameParams = Parameters::fieldNames(':name', $fieldNames);
|
||||
Custom::nonQuery(Query\RemoveFields::byContains($tableName, $nameParams),
|
||||
array_merge(Parameters::json(':criteria', $criteria), $nameParams));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove fields from documents via a JSON Path match query (`@?`; PostgreSQL only)
|
||||
*
|
||||
* @param string $tableName The table in which documents should have fields removed
|
||||
* @param string $path The JSON Path match string
|
||||
* @param array|string[] $fieldNames The names of the fields to be removed
|
||||
* @throws DocumentException If the database mode is not PostgreSQL, or if an error occurs
|
||||
*/
|
||||
public static function byJsonPath(string $tableName, string $path, array $fieldNames): void
|
||||
{
|
||||
$nameParams = Parameters::fieldNames(':name', $fieldNames);
|
||||
Custom::nonQuery(Query\RemoveFields::byJsonPath($tableName, $nameParams),
|
||||
array_merge([':path' => $path], $nameParams));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user