nexgen
nexgen

Reputation: 57

How to share data between two app maker apps?

I have created two app maker apps for different purposes. However, there are some data which is common between two apps.

How can I access/connect data between those app maker apps?

Upvotes: 1

Views: 377

Answers (1)

The Support Group
The Support Group

Reputation: 343

You will need to setup a Custom Google Cloud SQL instance. Then you can point both apps at the instance in Settings > Database > Switch to a Custom Cloud SQL Database

EDIT:

The other option is setting up a calculated reference to a model in another app.

  1. Grant access to App2 in App1's Google Cloud SQL Instance Authorization Settings (see above link).
  2. Create a Calculated model in App2.
  3. In the Datasource query:

    var conn = Jdbc.getCloudSqlConnection('jdbc:google:mysql://INSTANCE_CONNECTION_NAME/DATABASE_NAME', 'USERNAME', 'PASSWORD');
    var stmt = conn.prepareStatement("SELECT * from TABLE_NAME");
    var res = stmt.executeQuery();
    var records = [];
    while(res.next()) {
      var record = app.models.MODEL_NAME.newRecord();
      record.FIELD_1 = res.getString(1);
      record.FIELD_2 = res.getString(2);
      record.FIELD_3 = res.getString(3);
      records.push(record);
    }
    
    res.close();
    stmt.close();
    conn.close();
    
    return records;
    

Upvotes: 2

Related Questions