I see this community thread for the best practices of opening a Realm is to open it once and use it through out the lifecycle of the app.
I have 3 doubts:
-
If I have 12 Realm Tables, then I should open the real with all those 12 tables at once? Imagine 50 tables as well and upto complexity of n tables.
-
I am working with flutter and a mobile app and planning to create a class of DBService which will host the Realm open and CRUD operations. Is this the best practice? This DB service class will only be used in my Blocs and not in the UI.
typedef DBClass = Realm;
typedef DBTableClass = SchemaObject;
typedef DBAppUserClass = TBAppUser;
typedef DBAssetTypeClass = TBAssetType;
typedef DBIncomeClass = TBIncome;
class DBService {
static Configuration dbConfig = Configuration.local([
DBAppUserClass.schema,
DBAssetTypeClass.schema,
DBIncomeClass.schema,
DBAssetTypeClass.schema]);
static DBClass dbAgent = DBClass(dbConfig);
addUser(DBAppUserClass target) {
dbAgent.write(() {
dbAgent.add(target);
});
}
RealmResults<DBAssetTypeClass> getAllAssets() {
return dbAgent.all<DBAssetTypeClass>();
}
- What is “main isolate” which is being asked in the above referenced community thread?