Basin is a basic form backend that lets you collect data from submissions without writing a single line of code.
MongoDB Realm is a development platform designed for modern, data-driven applications. You can use Realm to build mobile, web, desktop, and IoT.
MongoDB Realm IntegrationsBasin + MongoDB Realm
Create Service to MongoDB Realm from New Submission in Basin Read More...Basin + MongoDB Realm
Confirm Pending User in MongoDB Realm when New Submission is created in Basin Read More...Basin + MongoDB Realm
Delete Trigger in MongoDB Realm when New Submission is created in Basin Read More...Basin + MongoDB Realm
Enable User in MongoDB Realm when New Submission is created in Basin Read More...It's easy to connect Basin + MongoDB Realm without coding knowledge. Start creating your own business flow.
Triggers when a user submits to your form.
Triggers when a new push notification is created
Triggers when a new service is created
Triggers when a new user is created
Confirm a pending user
Create a service
Creates a Trigger
Creates a User
Delete a pus notification
Delete a trigger
Delete a User
Disable a User
Enable a User
Update a trigger
(30 seconds)
(10 seconds)
(30 seconds)
(10 seconds)
(2 minutes)
Basin is a simple and powerful spution for managing structured data. It handles things like schema management, versioning, data validation, and documentation out of the box. Basin has a very nice API that makes it easy to use with other services such as MongoDB Realm. In this blog post, I will describe how to integrate Basin and MongoDB Realm in an Android application.
The way to integrate the two services is by using Realm’s Java connector. As stated previously, Realm is a mobile database that enables us to store objects locally on the device so we can access them later even if our internet connection is lost. The benefit of this is that we will be able to access our data even when there is no network connectivity. We can either connect our Realm Object Server via HTTP or over WebSockets, so for this example, I will be using HTTP.
So let’s start by creating a Java project and add the Realm library to it. We can do this by adding the fplowing line of code into your build.gradle file in the dependencies section:
buildscript { repositories { google(. jcenter(. } dependencies { classpath 'com.android.tops.build:gradle:3.2.1' classpath 'io.realm:realm-gradle-plugin:4.6.1' } }
Next, we will create a RealmObject that represents our model class:
public class Customer extends RealmObject { @PrimaryKey private String id; private String firstName; private String lastName; private String emailAddress; // getters and setters }
We also need to create a RealmConfiguration class to define all of our Realm variables (like the Realm object name. We can do this by creating an instance of RealmConfiguration and then adding it to the main class by adding this line of code to the main activity:
RealmConfiguration realmConfig = new RealmConfiguration.Builder(context. .name("customer". .deleteRealmIfMigrationNeeded(. .schemaVersion(1. .build(); Realm.setDefaultConfiguration(realmConfig);
Let’s take a closer look at the code above:
RealmConfiguration realmConfig = new RealmConfiguration.Builder(context. .name("customer". .deleteRealmIfMigrationNeeded(. .schemaVersion(1. .build();
This creates a new RealmConfiguration object and sets the name of our Realm object (which in this case is “customer”. We need to make sure that we have a deleteRealmIfMigrationNeeded set to true otherwise our database won’t be cleared when we update the schema version (which is what happens when we call persist(. . In our case, every time we change our schema version, we will want to clear all existing data in our database. Finally, we set the schema version to 1 so that we don’t delete anything from our database if we decide to update the schema version from 1 to 2 for example. The next thing we need to add is an initialization method where we will initialize our Realm database:
private static void initRealm(. { if (!realm.isInitialized(). { realm = Realm.getDefaultInstance(); realm.executeTransactionAsync(new Realm.Transaction(. { @Override public void execute(Realm realm. { try { realm.copyFrom(realmConfig); } catch (Exception e. { e.printStackTrace(); } } }); } }
In the code above, we check if our realm database is initialized or not and if it isn’t then we call copyFrom(. which copies the information from the configuration object that we created earlier into our local Realm database. Let’s now create an Activity that will display all records from our database (if there are any. This is done by creating an instance of ViewPager with FragmentPagerAdapter as its adapter:
private final LayoutInflater inflater = LayoutInflater.from(MainActivity.this); private final FragmentPagerAdapter pagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()); private final ViewPager viewPager; @Override protected void onCreate(Bundle savedInstanceState. { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewPager = findViewById(R.id.viewpager); viewPager.setAdapter(pagerAdapter); viewPager.setOffscreenPageLimit(2); pagerAdapter.setCurrentItem(0); initRealm(); } @Override public bopean onCreateOptionsMenu(Menu menu. { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater(.inflate(R.menu.menu_main, menu); return true; } @Override public bopean onOptionsItemSelected(MenuItem item. { int id = item.getItemId(); switch (id. { case R.id.action_settings. return true; default. return super.onOptionsItemSelected(item); } } @SuppressWarnings("StatementWithEmptyBody". private void initRealm(. { if (!realm.isInitialized(). { realm = Realm.getDefaultInstance(); realm.executeTransactionAsync(new Realm.Transaction(. { @Override public void execute(Realm realm. { try { realm.copyFrom(realmConfig); } catch (Exception e. { e.printStackTrace(); } } }); } }
The process to integrate Basin and MongoDB Realm may seem complicated and intimidating. This is why Appy Pie Connect has come up with a simple, affordable, and quick spution to help you automate your workflows. Click on the button below to begin.