Plugin backend how to connect to bubble.io app database

Hey All,

I’m creating a plugin with server side action. Input is database ID from specific table, during plugin execution, several tables / records will be retrieved and output is one big JSON.

Question: How I can query database of specific app, where the plugin is installed, to get the data?

My first thought is to pass URL of the API into the plugin, so it can execute the queries via API, but not sure if this is the best strategy. Another consideration is the authentication as I would like to update certain records, but this should be done only by plugin, not by unauthenticated user.

Any ideas how to achieve this will be highly appreciated :blush:

There’s a native way to do this from within the plugin.
You can pass the data you need to the action or the element that your plugin exposes.

Then you can access these via the plugin editor.
For example, if I pass a list of users to the plugin, you can access their details by doing this:

var inputs = properties.myInputs;
var length = properties.myInputs.length();

for (var itms=0; itms < length; itms++) {
  const thisInput = inputs.get(itms,1)[0];

  console.log( thisInput.get("_id") ); // prints the thing's unique ID
  console.log( thisInput.get("name_text") ); // prints the thing's field 'name'

}

Hope this helps!


Cheers,
Ranjit from Atomic Fusion

Explore and reuse the community’s Bubble assets & Accelerate your Bubble development with Atomic Fusion

1 Like

My scenario is different as I don’t know the data that needs to be passed.

This is the scenario. I have 3 tables that are connected 1:many via IDs + need to process the values.

table 1:
{ data, data link: [table2id, table2id, table2id]}

table 2:
{ id, data, data link: [table3id, table3id, table3id]}
{ id, data, data link: [table3id, table3id, table3id]}
...

Rather than doing this processing on frontend, my idea was to pass the ID of the record from table1 into plugin, then within plugin do the queries based on IDs into other tables and then return to frontend one joined JSON.

Having looked under the hood of a lot of plugins that have data search capabilities (search&autocomplete plugin for example), you have to pass the entire list of things to search from into the plugin.

So I’d provide an input for all the possible things you want to search from, as well as one for the ids.

In the plugin, it would grab all the ids from the complete list inputted, find ones that have ids matching with any of the target ids you provided and then return the results.

I highly recommend looking at the plugin code for the one linked above if you’re interested in building this out. If I understood correctly, there is a similar target functionality.

1 Like

Thank you so much for your help!

1 Like