Skip to content

Instantly share code, notes, and snippets.

@msarsha
Created January 22, 2020 09:58
Show Gist options
  • Save msarsha/2d8d7724654c68bb9cf99e1bcccb112b to your computer and use it in GitHub Desktop.
Save msarsha/2d8d7724654c68bb9cf99e1bcccb112b to your computer and use it in GitHub Desktop.
// --------
const singleTree = {
branches: [],
operation: null,
value: {
dataSource: 'customer props',
fieldOrFunc: 'installation date',
operation: {
name: 'between',
value: ['date', 'date']
}
}
};
/*
|
| ----
OR
| ----
|
*/
const simpleTree = {
branches: [
{
branches:[],
operation: null,
value: {
dataSource: 'customer props',
fieldOrFunc: 'installation date',
operation: {
name: 'between',
value: ['date', 'date']
}
}
},
{
branches:[],
operation: null,
value: {
dataSource: 'customer props',
fieldOrFunc: 'installation date',
operation: {
name: 'between',
value: ['date', 'date']
}
}
}
],
operation: 'OR'
};
/*
| | ----
| OR
| | ----
AND
|
| ------------
*/
const complexTree = {
branches: [
{
branches: [
{
branches:[],
operation: null,
value: {
dataSource: 'customer props',
fieldOrFunc: 'installation date',
operation: {
name: 'between',
value: ['date', 'date']
}
}
},
{
branches:[],
operation: null,
value: {
dataSource: 'customer props',
fieldOrFunc: 'installation date',
operation: {
name: 'between',
value: ['date', 'date']
}
}
}
],
operation: 'OR'
},
{
branches: [],
operation: null,
value: {
dataSource: 'customer props',
fieldOrFunc: 'installation date',
operation: {
name: 'between',
value: ['date', 'date']
}
}
}
],
operation: 'AND'
};
/*
| | ----
| OR
| | ----
AND
| | ----
| OR
| | ----
*/
const complexTree2 = {
branches: [
{
branches: [
{
branches:[],
operation: null,
value: {
dataSource: 'customer props',
fieldOrFunc: 'installation date',
operation: {
name: 'between',
value: ['date', 'date']
}
}
},
{
branches:[],
operation: null,
value: {
dataSource: 'customer props',
fieldOrFunc: 'installation date',
operation: {
name: 'between',
value: ['date', 'date']
}
}
}
],
operation: 'OR'
},
{
branches: [
{
branches:[],
operation: null,
value: {
dataSource: 'customer props',
fieldOrFunc: 'installation date',
operation: {
name: 'between',
value: ['date', 'date']
}
}
},
{
branches:[],
operation: null,
value: {
dataSource: 'customer props',
fieldOrFunc: 'installation date',
operation: {
name: 'between',
value: ['date', 'date']
}
}
}
],
operation: 'OR'
}
],
operation: 'AND'
};
/*
| | | ----
| | OR
| | | ----
| AND
| | | ----
| | OR
| | | ----
OR
| | ----------
| OR
| | ----------
*/
const complexTree3 = {
branches: [
{
branches: [
{
branches: [
{
branches: [],
operation: null,
value: {
dataSource: 'customer props',
fieldOrFunc: 'installation date',
operation: {
name: 'between',
value: ['date', 'date']
}
}
},
{
branches: [],
operation: null,
value: {
dataSource: 'customer props',
fieldOrFunc: 'installation date',
operation: {
name: 'between',
value: ['date', 'date']
}
}
}
],
operation: 'OR'
},
{
branches: [
{
branches: [],
operation: null,
value: {
dataSource: 'customer props',
fieldOrFunc: 'installation date',
operation: {
name: 'between',
value: ['date', 'date']
}
}
},
{
branches: [],
operation: null,
value: {
dataSource: 'customer props',
fieldOrFunc: 'installation date',
operation: {
name: 'between',
value: ['date', 'date']
}
}
}
],
operation: 'OR'
}
],
operation: 'AND'
},
{
branches: [
{
branches: [],
operation: null,
value: {
dataSource: 'customer props',
fieldOrFunc: 'installation date',
operation: {
name: 'between',
value: ['date', 'date']
}
}
},
{
branches: [],
operation: null,
value: {
dataSource: 'customer props',
fieldOrFunc: 'installation date',
operation: {
name: 'between',
value: ['date', 'date']
}
}
}
],
operation: 'OR'
}
],
operation: 'OR'
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment