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

ds1

  1. Click on the required dataset

ds2

  1. Click on Rules

ds3

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.

ds4

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

ds5

  1. Click on Create Rule

ds6

  1. Fill in the fields according to your requirements

ds7

In this guide, we’ll create a rule that allows reading all data.

  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

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

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

ds8

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

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

ds9

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

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

ds10

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

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

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

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

ds11

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.

ds12

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

ds13

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

ds14

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.

ds15

ds16

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

ds17

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.

ds18

  1. Condition - The condition can be true or false according to your requirement

True: Above selected groups are allowed to perform the selected action (Multi-Read, Create, Read, Update, Delete) of the targeted dataset

False: Above selected groups are not allowed to perform the selected action (Multi-Read, Create, Read, Update, Delete) of the targeted dataset