imports/vx/server/code/vxapp.js
/**
     * Restore a previously-created domain snapshot.
     *
     * @param {object} formObject Form object from deployment modal.
     * @return {object} Result object.
     */
Restore a previously-created domain snapshot.
@param {object} formObject Form object from deployment modal.
@return {object} Result object.
Restore a previously - created domain snapshot . @param { object } formObject Form object from deployment modal . @return { object } Result object .
executeDeploymentRestore(formObject) {
        let history = History.findOne( { domain: formObject.targetDomain } )
        if (!history) {
            OLog.error(`vxapp.js executeDeploymentRestore *fail* unable to find history of targetDomainName=${Util.fetchDomainName(formObject.targetDomain)}`)
            return { success : false, icon : "BUG", key : "common.alert_transaction_fail_unable_to_find_deployment_history",
                variables: { targetDomainName : Util.fetchDomainName(formObject.targetDomain) } }
        }
        const snapshot = history.snapshots[formObject.snapshotIndex]
        const deploymentCollections = VXApp.getAppDeploymentCollections()
        _.each(snapshot.collections, snapshotCollection => {
            OLog.debug(`vxapp.js executeDeploymentRestore collectionName=${snapshotCollection.collectionName} record count=${snapshotCollection.records.length}`)
            const collection = _.find(deploymentCollections, deploymentCollection => deploymentCollection._name === snapshotCollection.collectionName)
            if (!collection) {
                OLog.error(`vxapp.js executeDeploymentRestore unable to find deployment collection matching collectionName=${snapshotCollection.collectionName}`)
                return
            }
            let sourceRecords = snapshotCollection.records
            let targetRecords = collection.find( { domain: formObject.targetDomain } ).fetch()
            VXApp.synchronizeCollection(formObject, collection, sourceRecords, targetRecords)
        })
        OLog.debug(`vxapp.js executeDeploymentRestore *success* historyId=${history._id} index=${formObject.snapshotIndex}`)
        return { success : true, icon : "HISTORY", key : "common.alert_deployment_restored_success",
            variables : { targetDomainName : Util.fetchDomainName(formObject.targetDomain), dateTime : Util.formatDateTime(snapshot.date) } }
    }
executeDeploymentRestore ( formObject ) { let history = History . findOne ( { domain : formObject . targetDomain } ) if ( ! history ) { OLog . error ( ` ${ Util . fetchDomainName ( formObject . targetDomain ) } ` ) return { success : false , icon : "BUG" , key : "common.alert_transaction_fail_unable_to_find_deployment_history" , variables : { targetDomainName : Util . fetchDomainName ( formObject . targetDomain ) } } } const snapshot = history . snapshots [ formObject . snapshotIndex ] const deploymentCollections = VXApp . getAppDeploymentCollections ( ) _ . each ( snapshot . collections , snapshotCollection => { OLog . debug ( ` ${ snapshotCollection . collectionName } ${ snapshotCollection . records . length } ` ) const collection = _ . find ( deploymentCollections , deploymentCollection => deploymentCollection . _name === snapshotCollection . collectionName ) if ( ! collection ) { OLog . error ( ` ${ snapshotCollection . collectionName } ` ) return } let sourceRecords = snapshotCollection . records let targetRecords = collection . find ( { domain : formObject . targetDomain } ) . fetch ( ) VXApp . synchronizeCollection ( formObject , collection , sourceRecords , targetRecords ) } ) OLog . debug ( ` ${ history . _id } ${ formObject . snapshotIndex } ` ) return { success : true , icon : "HISTORY" , key : "common.alert_deployment_restored_success" , variables : { targetDomainName : Util . fetchDomainName ( formObject . targetDomain ) , dateTime : Util . formatDateTime ( snapshot . date ) } } }
Restore a previously-created domain snapshot.
Restore a previously - created domain snapshot .