Delete Rows
You can delete specified rows from your sheet. Perform a DELETE request with the row identifiers.
Structuring the JSON
Create a JSON string with the key condition and optionally limit.
{
"condition": {"column": "value", ...},
"limit": INTEGER (optional)
}
The value of the condition property is used to search for matching rows in the sheet. It behaves similar to the search param when searching for rows.
These matched rows are then deleted.
The number of rows deleted is limited as per the limit option, if specified.
Performing the request
Let's delete all posts by Shiven Sinha in the Blog Posts Sheet. This request accomplishes that.
$ curl "https://api.steinhq.com/v1/storages/5cc158079ec99a2f484dcb40/Sheet1" \
-X DELETE \
-H "Content-Type: application/json" \
-d '{"condition": {"author": "Shiven Sinha"}}'
const SteinStore = require("stein-js-client");
const store = new SteinStore(
"https://api.steinhq.com/v1/storages/5cc158079ec99a2f484dcb40"
);
store
.delete("Sheet1", {
search: { author: "Shiven Sinha" }
})
.then(res => {
console.log(res);
});
<script src="https://unpkg.com/stein-js-client"></script>
<script>
const store = new SteinStore(
"https://api.steinhq.com/v1/storages/5cc158079ec99a2f484dcb40"
);
store
.delete("Sheet1", {
search: { author: "Shiven Sinha" }
})
.then(res => {
console.log(res);
});
</script>
Return value
The number of rows deleted is returned as JSON. For example,
{ "clearedRowsCount": 1 }