parse-platformparse-javascript-sdk

Set StorageController in Parse-SDK-JS


i am developing an ionic app so i want to use the ionic storage module to store data on the device.

Parse is the backend so i have to tell the parse SDK that it should use the Ionic Storage. I build a StorageController like the included react-native one the use the ionic storage, but can't find a way to set the StorageController without cloning the SDK, alter Storage.js and add another else clause

if (process.env.PARSE_BUILD === 'react-native') {
  CoreManager.setStorageController(require('./StorageController.react-native'));
} else if (process.env.PARSE_BUILD === 'ionic') {
  CoreManager.setStorageController(require('./StorageController.ionic'));
} else if (process.env.PARSE_BUILD === 'browser') {
  CoreManager.setStorageController(require('./StorageController.browser'));
} else {
  CoreManager.setStorageController(require('./StorageController.default'));
}

is there a way to call CoreManager.setStorageController on the fly while parse initialisation?


Solution

  • I think you should be able to do this:

    const Parse = require('parse');
    const ionicController = require('./StorageController.ionic');
    
    Parse.CoreManager.setStorageController(ionicController);