Home Reference Source Repository
public class | source

Differ

You can directly use instance of this class. differ

Diff projects or schemas and get changes between them

Method Summary

Public Methods
public

Check if the changes contain a change that removes data.

public

diffProject(projectId: String, oldProject: Project, project: Project): Changes

Get changes by comparing 2 projects

public

diffProjects(oldProjects: Projects, projects: Projects): Changes

Get changes by comparing 2 sets of projects

public

diffSchema(projectId: String, schemaId: String, oldSchema: Schema, schema: Schema): Changes

Get changes by comparing 2 schemas

Protected Methods
protected

Sort changes

Public Methods

public containsBreakingChanges(changes: Changes): Boolean source

Check if the changes contain a change that removes data.

The following changes are breaking

  • schema.remove
  • column.remove
  • column.typechange

Params:

NameTypeAttributeDescription
changes Changes

An array of changes

Return:

Boolean

Example:

var breakingChanges = [
  {
    change: 'column.remove',
    schemaId: '1',
    columnId: '1',
    oldColumn: {
      name: 'id',
      type: 'integer'
    }
  }
];
differ.containsBreakingChanges(breakingChanges);

public diffProject(projectId: String, oldProject: Project, project: Project): Changes source

Get changes by comparing 2 projects

Params:

NameTypeAttributeDescription
projectId String

Project id

oldProject Project

The old project

project Project

The new project

Return:

Changes

An array of changes

Example:

var oldProject = null;
var project = {
  '1': {
    name: 'users',
    columns: {
      '1': {
        name: 'id',
        type: 'uuid'
      }
    }
  }
};
var changes = differ.diffProject(projectId, oldProject, project);

public diffProjects(oldProjects: Projects, projects: Projects): Changes source

Get changes by comparing 2 sets of projects

Params:

NameTypeAttributeDescription
oldProjects Projects

The old projects

projects Projects

The new projects

Return:

Changes

An array of changes

public diffSchema(projectId: String, schemaId: String, oldSchema: Schema, schema: Schema): Changes source

Get changes by comparing 2 schemas

Params:

NameTypeAttributeDescription
projectId String

Project id

schemaId String

Schema id

oldSchema Schema

The old schema

schema Schema

The new schema

Return:

Changes

An array of changes

Example:

var oldSchema = {};
var schema = {
  name: 'users',
  columns: {
    '1': {
      name: 'id',
      type: 'uuid'
    }
  }
};
var changes = differ.diffSchema(schemaId, oldSchema, schema);

Protected Methods

protected sortChanges(changes: Changes): Changes source

Sort changes

Params:

NameTypeAttributeDescription
changes Changes

Changes to sort

Return:

Changes

Sorted changes