Datastore Dynamic Data
buildfire.datastore
#
Datastore Dynamic Data is a feature that allows plugin developers to combine multiple requests to certain supported data types in one request.
Dynamic Data can be used by adding a special _buildfire
object inside your main datastore data object. This special object, describes the data needed to be fetched. Such object can be placed anywhere within a datastore data object.
#
Why use Dynamic Data?While this doesnt apply everywhere, there are some instances where you cannot store data locally within your data object because it keeps changing.
Imagine having a plugin that displays a list of images and titles that link to other plugins in the app. You could acomplish this by getting the list of plugins with buildfire.pluginInstance.search
and store the result in datastore as normal data, but there is one issue with that approach. If user changes the name of the plugin, plugin icon or deletes the icon, your plugin will not be aware of those changes. If you were developing a folder plugin that the app owner could add other plugin instances in. You cant simply save the selected plugin instances titles , images, etc. because these are referencing data that may be changes outside of your plugin. If you do save it locally it would simply be a snapshot in time. With Dynamic Data injection you can just keep reference to the plugins and at run time the datastore will inject the latest data properties into your object. Datastore dynamic data steps in to resolve that problem.
You can see example implementation on BuildFire Folder Plugin
#
Data StructureThe _buildfire
object should have the following structure:
#
Example#
MethodsgetWithDynamicData()
#
buildfire.datastore.getWithDynamicData(tag, callback)
After the object has been saved to the datastore (save / insert / update) using the structure explained above getWithDynamicData can be used to get the data back along with the dynamic data result injected.
note
The regular datastore get would return the data as is and will not have dynamic data injected. It is recommended to use the regular datastore get method when there is no use of the dynamic data result in the current invocation as it would be perform faster.
tag
#
Name | Type | Required | Description | Default |
---|---|---|---|---|
tag | string | no | Key used to differentiate your content saved in datastore. ex(settings or questions ) etc. |
callback(err, result)
#
Callback function after dynamic data is fetched
Name | Type | Description |
---|---|---|
err | string | error string, null when operation is successful |
result | object | Datastore record with dynamic data attached |
dataType
)#
Supported Data Types (pluginInstance
#
Retrieves plugin instances. Data holds a plugin instance id or an array of ids to be retrieved in result as an array.
Name | Type | Description |
---|---|---|
data | [string] or string | Plugin instance id or array of plugin instance ids |
dataType | string | pluginInstance |
#
Example DatapluginType
#
Retrieves plugin types. Data holds a plugin type id or an array of ids to be retrieved in result as an array.
Name | Type | Description |
---|---|---|
data | [string] or string | Plugin type id or array of plugin type ids |
dataType | string | pluginType |