Determining the DB type of an object

My app has scenarios where an object passed to a function might either be from the DB or OnlineDB.

When trying to write one function to handle both cases, I receive the error Cannot add an object in OnlineDB to a batch in DB.

How can I create a batch based on the object passed to the function?

This was solved by using a hidden property of the DB object

function doesThings(some_object) {
    var _DB;
    switch (some_object._adapter._description) {
        case 'DB':
            _DB = DB;
        case 'OnlineDB':
            _DB = OnlineDB;
        case 'LocalDB':
            _DB = LocalDB;

   var batch = new _DB.Batch();

Iā€™m not sure hidden properties like this will always be available, so be sure to test your app on beta or RC runtime releases.

1 Like