Hypi treats scalar array differently. The scalar arrays are not stored directly with other scalar fields. Hence, an unlimited number of items can be added to a scalar array.
deleteScalars function is used to delete the data from scalar arrays
Let’s see how to use the deleteScalars
function.
- If you want to delete data permanently you can use the deleteScalars function
deleteScalars(
type: HypiMutationType!
field: String!
values: [String!]!
arcql: String!
): Int!
- Select the object using arcql query statement
- Insert values to be deleted from a
field
in thevalues
parameter.
We will use the following schema.
type deleteScalarArray {
fld1: [Int]
}
Let’s create a deleteScalarArray object by inserting some values in fld1.
mutation {
upsert(values: { deleteScalarArray: [{ fld1: [1, 2, 3, 4, 5] }] }) {
id
}
}
#result
{
"data": {
"upsert": [
{
"id": "01FHWWRSJ192G1A7AXCGM1Q9VK"
}
]
}
}
Sample Query
Now we will delete values 4 and 3 from the fld1 Integer array using the deleteScalars function.
mutation{
deleteScalars(
type:deleteScalarArray,
field:"fld1",
values:["4","3"],
arcql:"hypi.id ='01FHWWRSJ192G1A7AXCGM1Q9VK'"
)
}
#result
{
"data": {
"deleteScalars": 2
}
}
Output
The function returns the number of values deleted.
Query with Variables
mutation deleteScalarArrays(
$type: HypiMutationType!
$field: String!
$values: [String!]!
$arcql: String!
) {
deleteScalars(type: $type, field: $field, values: $values, arcql: $arcql)
}
#query variables
{
"type": "deleteScalarArray",
"field":"fld1",
"values":["1"],
"arcql":"hypi.id ='01FHWWRSJ192G1A7AXCGM1Q9VK'"
}
Check the POSTMAN collection for the delete scalars
requests in different programming languages! Click </>
and choose the programming language of your choice.
Don’t forget to insert your own Authorization key and Hypi Domain under Headers to test the results!