Hello,
is there any better way to get data from the plugin store not only by the key?
For example, I have an attribute “name” and I want to get only the row out of the plugin store with a given name.
For now I just get all plugin store entries of my plugin and iterate over all rows until I find the row I am looking for.
Yeah the problem was that the PluginStore is only key-value.
But if a plugin needs multiple attributes assigned to a key, it gets imposible for a sql query to search for a specific attribute.
As a solution I rewrote my plugin to use the ActiveRecord instead, so I can specify my schemes like I want and use the ActiveRecord interface to query for things.
Hi Jafeth,
I generated a new model for my plugin.
I think I used
rails generate migration modelname
It is no problem to execute another db migration on development in the discourse root
bundle exec rake db:migrate
Sure the data stored in ActiveRecord is persistent and will not be deleted even if you delete your plugin.
But for me it is ok. My plugin doesn’t generate that much data.
On a production system make sure that the model migration file is there before the script executes the migration or you have to migrate by hand.