Error While Configuring SQl Data Adapter


#1

I am trying to configure Sql Data Adapter by following the steps as mentioned in the following link:

https://docs.realm.io/platform/develop/integration/data-connector-api/mssql-data-connector

At Step : "node loader.js ", I am getting the error as below.
If anyone know about this please provide your valuable suggestions.


#2

@javeed6373 That error indicates a certificate error - how did you configure your cert? Can you send me an email at [email protected] and we can take a look.


#3

@ianward Thanks its works…

Database tables and ROS sync successfully…

Now i m trying to sync with database views can i do that?


#4

@javeed6373 The easiest way would be to sync the full db and then use partial sync to distribute it to separate users (which is what I assume is what you are trying to do) like so:

There are also configurations in the adapter script to do this, for instance:

mapPostgresChangeToRealmPath: (tableName, props) => ‘/${props.userID}/myRealm’

Given a tableName and props you can return the realm path to map to. You can inject any sort of logic in there that you need.


#5

@ianward Thanks for the response…

actually i want to create custom view model of database views in realmmodel.js…

simple i have create one table in database and create realm model with the below example

const Bus = {
name: ‘Bus’,
primaryKey: ‘vehicle’,
properties: {
Scheduleid: type: ‘Schedule’,
vehicle: ‘int’,
fleet_id: { type: ‘string’, optional: true },
last_main: { type: ‘date’, optional: true }
}
};

and then i have create view with the joins in database and i m able to create realm model for view…

please advice.


#6

@javeed6373 The SQL Server adapter works by utilizing the built-in replication for MSSQL with Change Tracking. Change Tracking corresponds to particular tables on the MSSQL db. Can views be linked to replicate to other datasources via change tracking? Please advise.

The adapter supports JOIN tables and the Realm Platform has the ability to use a query to sync data to a particular user which is very similar to a view


#7

@ianward Let we have three tables. Customer1, Customer2 and Customer3. I created a view in MSSQL which combines data (Union) from all three tables and send to the client side via Web-services. The client end gets CustomerX as a model.
Now i want to use CustomerX model schema for updates between client end and MSSQL via Realm.

Can you help me with this scenario. how can i write adapter.js?


#8

@imhafeez You should sync all those tables to the data adapter and then based on what you want in the client app you can see you can use partial sync to pull in one of those tables, some columns on two of those tables, or all of those tables.


#9

Thanks @ianward.
Can you please help me with objective c code with example how we can combine two or more tables using partial sync. as i couldn’t find an example in documentation.


#10

@imhafeez Can you please share the starting input and what you want/expect the output to be? The schema would help here


#11

@ianward Thanks i got it. But i am facing a problem in partial Sync. Please have a look into my code:

RLMSyncUser *user = [RLMSyncUser currentUser];
// Create the configuration
NSURL *syncServerURL = [NSURL URLWithString: kRealmInstance];

RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration];
config.syncConfiguration = [[RLMSyncConfiguration alloc] initWithUser:user realmURL:syncServerURL];

[config.syncConfiguration setIsPartial:YES];
[RLMRealmConfiguration  setDefaultConfiguration:config];

NSError *error;
RLMRealm *realm = [RLMRealm realmWithConfiguration:config error:&error];


[realm subscribeToObjects:[Customer class] where:[NSString stringWithFormat:@"FirstName CONTAINS 'a'"] callback:^(RLMResults * _Nullable results, NSError * _Nullable error) {
         
   
    if (error) {
        NSLog(error.description);
    }
    
}];

On subscribeToObjects it crashes giving me log.i.e

libc++abi.dylib: terminating with uncaught exception of type std::logic_error: A partial sync query can only be registered in a partially synced Realm

I am using Realm v3.2.0


#12

@imhafeez What version of ROS are you using?


#13

@imhafeez you have to set isPartial on a RLMSyncConfiguration object and then set config.syncConfiguration to that. config.syncConfiguration returns a copy of the object, so mutating it doesn’t do anything


#14

Thanks. :thumbsup: resolved