Deleting Realms

Deleting Realms is an essential part of the development process. It helps start your data off in a clean slate. Fortunately we offer two ways of handling this.

Delete Realm APIs

const ROS = require('realm-object-server')
const myRosInstance = require('realm)

/**
* This deletes all realms EXCEPT for reserved realms like __permissions etc...
*/
myRosInstance.deleteRealms() 
    .then(realmPaths => {
        console.log(`We deleted ${realmPaths.length} realms`)
    })
    .catch(err => console.err(err))

We even allow taking a RegExp or a list of realm paths.

myRosInstance.deleteRealms(/^\/([0-9a-f]+)\/private$/)
    .then(realmPaths => {
        console.log(`We deleted ${realmPaths.length} realms`)
    })
    .catch(err => console.err(err))

myRosInstance.deleteRealms([
        '/someRealmPath/explicitly', 
        /^\/([0-9a-f]+)\/private$/, 
        'cool/path'
    ])
    .then(realmPaths => {
        console.log(`We deleted ${realmPaths.length} realms`)
    })
    .catch(err => console.err(err))

Factory Reset

We've added a functionality called "Factory Reset" to allow people to easily use the same ROS instance for development and for testing. factoryReset() returns a Promise<any> describing the status of everything.

We make a distinction between deleting realms and a Factory Reset. A Factory reset will:

  1. Delete all realms, including reserved ones (realm paths that begin with __)
  2. Deletes all user instances
  3. Any connected client will be forced off and their realms deleted.
myRosInstance.factoryReset()
    .then(status => {
        // we are good
        console.log(status)
    })
    .catch(err => console.error(err))

results matching ""

    No results matching ""