# remove

## Description

Removes certain data from a dataset.

## Input / Parameter

| Name    | Description                                           | Input Type   | Default | Options | Required |
| ------- | ----------------------------------------------------- | ------------ | ------- | ------- | -------- |
| dataset | The name of the dataset that is created in Services.  | Text         | -       | -       | Yes      |
| filter  | The filters to be applied.                            | FilterFormat | -       | -       | No       |
| extra   | The stored value that is passed to all the callbacks. | Any          | -       | -       | No       |

### FilterFormat (Object)

The format used for filtering in the parameter `filter`.

| Key      | Description                                    | Input Type | Default | Options | Required |
| -------- | ---------------------------------------------- | ---------- | ------- | ------- | -------- |
| operator | Query operators used to filter multiple times. | Text       | And     | Or, And | No       |
| data     | Set of rules for another group of queries.     | List       | -       | -       | No       |

#### data (List)

Will contain a list of one (1) or more objects with the following structure (dataset, operator, value) and contain zero (0) or more objects with the same structure (FilterFormat only). This can be another FilterFormat to create grouped queries.

| Key      | Description                                                    | Input Type | Default | Options                                                                                                                                                                     | Required |
| -------- | -------------------------------------------------------------- | ---------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| dataset  | The dataset to filter.                                         | Text       | -       | -                                                                                                                                                                           | No       |
| field    | The field to be filtered.                                      | Text       | -       | -                                                                                                                                                                           | Yes      |
| operator | Operators to be used for specific filtering.                   | Text       | -       | Equal, Not\_Equal, Is\_Null, Is\_Not\_Null, Greater\_Than, Greater\_Than\_Or\_Equal, Less\_Than, Less\_Than\_Or\_Equal, Like, Not\_Like, In, Not\_In, Between, Not\_Between | Yes      |
| value    | The value to perform the query, which depends on the operator. | Any        | -       | -                                                                                                                                                                           | No       |

## Output

| Description                        | Output Type |
| ---------------------------------- | ----------- |
| Returns the formatted information. | Object      |

### Object

| Key     | Description                                                             | Output Type |
| ------- | ----------------------------------------------------------------------- | ----------- |
| success | Boolean value to denote whether the function was executed successfully. | Text        |
| message | The message to print.                                                   | Text        |
| data    | Any additional message or data to print.                                | Text        |

## Callback

### callback

The action performed if this function runs successfully.

| Description                                 | Output Type |
| ------------------------------------------- | ----------- |
| Returns a boolean value if data is deleted. | Boolean     |

### errorCallback

The action performed if this function does not run successfully.

| Description               | Output Type |
| ------------------------- | ----------- |
| Returns an error message. | Text        |

## Example

In this example, we will remove an item from the local table data from their local storage.

```js
Note: This example will only work after the user has created the data using `Dataset.insert` function.
```

### Steps

1. Create a `Local Table` in the services panel in the service page if there is no table created yet. For the fields, add `name`and `title` as object key with Text type.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-b87cd62feb0cb7e6500969aefd8b62d33a145c59%2Fremove-step-1.png?alt=media)
2. Drag a button component to a page in the mobile designer.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-96907e394ff256b86e4e7e0950b81db1baab5a6b%2Fremove-step-2.png?alt=media)
3. Select the event `press` and drag the `Dataset.remove` function to the event flow and fill in the parameter. Drag a `Log.write` function below the `Dataset.remove` function and change the parameter type of the value parameter to `input`.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-37b31a63293afd8f26570bbbd3d41c66fb465f01%2Fremove-step-3.png?alt=media)
4. For the `filter` parameter, change it's type to a function / subflow and drag `Conversion.toObject` to the subflow. Then add `data` as an object key and change it's type to a function / subflow. and put `Conversion.toObject` inside it.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-27e74cea8614c8fb684c3da11c820905df59b58e%2Fremove-step-4.png?alt=media)
5. Drag the function `Conversion.toObject` to the new subflow. Then add `field`, `operator` and `value` as object keys with `name`, `like`, `n%` as their values respectively.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-9ac496bd4bf63b90a00e27861d639763110370f7%2Fremove-step-5.png?alt=media)

### Result

1. The data passed should be removed from the local table.
