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
-
Open your Appspotr app
-
Navigate to Data > Datasets
-
Click on the required dataset
-
Click on Rules
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.
Default-multi-read - This allows everyone to multi-read.
-
Click on Create Rule
-
Fill in the fields according to your requirements
In this guide, we’ll create a rule that allows reading all data.
-
Name: The name of the rule that you are creating
-
Groups: Selected group/s that are granted permission to use the action (You can multi-select groups here)
-
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'
Create - Allows the selected group/s to add data in a dataset
Note: This would apply to a logic block like ‘Add to dataset’
Read: Allows the selected group/s to read data in a dataset
Note: This would apply to a logic block like ‘Fetch dataset item’
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.
But you cannot use Multi-read together with any other action. If you are Multi-reading you have to perform that rule along.
-
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.
-
Variables: Variables feature allows you to dynamically change values
If you have a filter value which needs to be changed dynamically you can use the variables to fulfil that requirement.
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.
Once you hit save, it will appear in the Rules list.
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.
-
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