Dataset Rules

Now that you know how to create, update and delete datasets next thing you have to know about are the rules related to datasets.

What is a rule?

A way that we can use to manage dataset security. In the earlier version of Appspotr App builder, we used permissions to grant access, and now we are using Rules for that.

In this guide, we’ll be discussing how to create a rule to secure your dataset.

Create a dataset rule

  1. Open your Appspotr app

  2. Navigate to Data > Datasets

dru1

  1. Click on the required dataset

dru2

  1. Click on Rules

dru3

Once you click on rules you will be able to see 2 pre-defined rules named Default rules.

Default rules

  • Whenever you create a new dataset, 2 rules will be automatically created called the Default-read and Default-multi-read. These 2 rules can be immediately applied to grant access.

Default-read - This allows everyone to read.

dru4

Default-multi-read - This allows everyone to multi-read.

dru5

  1. Click on Create Rule

dr6

  1. Fill in the fields according to your requirements

dr9

  1. Name: The name of the rule that you are creating

  2. Groups: Selected group/s that are granted permission to use the action (You can multi-select groups here)

  3. Action: The action that you want to grant permission to

Now we’ll see how to create different Rules for each Actions and what types of situations we can use them.

Multi Read

Multi-Read allows the selected group/s to read all the data of a targeted dataset

dru11

This would apply to a logic block like 'Fetch dataset'

dru10

Create

Create allows the selected group/s to add data in a dataset

dru12

This would apply to a logic block like ‘Add to dataset’

dru13

Read

Read Allows the selected group/s to read data in a dataset

dru14

This would apply to a logic block like ‘Fetch dataset item’

dru15

Update

Update Allows the selected group/s to update data in a dataset

dru16

This would apply to a logic block like ‘Update item from dataset’

dru17

Delete

Delete Allows the selected group/s to delete data in a dataset

dru181

If you want, you can create a rule which allows performing all Create, Read, Update and Delete Actions.

dru19

But you cannot use Multi-read together with any other action. If you are Multi-reading you have to perform that rule along.

  1. Filters: Filters only make sense if the Action is Multi-Read - it means that it only works when you are reading more than one item in a dataset. The Filters button will be kept disabled if the Action is selected as Create, Read, Update or Delete

Once you click on Filters, you can fill in the , Filter Type and Value fields according to your requirement.

You can also filter by more than one value.

dru20

  1. Variables: Variables feature allows you to dynamically change values

dru21

If you have a filter value which needs to be changed dynamically you can use the variables to fulfil that requirement.

dru22

If you are going to use variables, here below is how you have to define your filter. You can use any name for the variable name, but when you are filling the value field under Filters you have to use the same name with the $ syntax and curly brackets.

dru23

Once you hit save, it will appear in the Rules list.

dru24

Now this has been added as a dynamic rule, you can connect the above value to your patchwork and once you preview your app, this value will be visible as an output. You can change or set the output through the patchwork.

How this variables option is useful?

Imagine that you are creating an app which has a dataset item to take age as an input. And you need to filter those age values comparing to a certain value (age≥25) at the stage where the app is being built. But once the app is built, you might want to change this comparing value to be dynamic at different instances, that is where you can use the variables option.

Another way to create a Dataset Rule

You don’t have to always naviagte to the Data>Dataset tab to create a dataset rule. Whenever you need to create a dataset rule for a certain logic block you can do it from the Structure Builder itself.

Click on the relevant Logic Block

dru25

Select the relevant Dataset

dru26

Click on select Dataset Rule and then Click on Add Rule

dru27

Now you can create the rule according to your requirment

dru28