Created
April 13, 2020 15:57
-
-
Save bwgjoseph/464a70b8cc806295a8819a17f1b0e2f7 to your computer and use it in GitHub Desktop.
schema example for o service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```js | |
// o-group service | |
// each of this group represent a single row in db (e.g group) | |
// template or phase type can all store together using type to differentiate | |
const group = { | |
_id: '12345', | |
name: 'template 1', | |
type: 'TEMPLATE', | |
status: 'ACTIVE' // not sure what to call this field, cause type is used for above purpose so just use status for now | |
} | |
const group2 = { | |
_id: '29292', | |
name: 'Phase 1', | |
type: 'PHASE', | |
} | |
// o-node service | |
// each of this node represent a single row in db (e.g node) | |
const node = { | |
_id: '54321', | |
unit: { | |
name: 'abc', | |
fmtion: 'kkk', | |
size: 1, | |
// and so on | |
}, | |
parentId: '12345', // belongs to template 1 | |
// this is root node, so dont have nodeParentId | |
} | |
const node2 = { | |
_id: '99999', | |
unit: { | |
name: 'def', | |
fmtion: 'nnn', | |
size: 2, | |
// and so on | |
}, | |
parentId: '12345', // belongs to template 1 | |
nodeParentId: '54321', // this node is under node 54321 | |
isAssistant: false, | |
}; | |
const node3 = { | |
_id: '77777', | |
unit: { | |
name: 'abc', | |
fmtion: 'kkk', | |
size: 1, | |
// and so on | |
}, | |
parentId: '29292', // belongs to template 1 | |
isAssistant: false, | |
// this is root node, so dont have nodeParentId | |
}; | |
``` | |
So by if I want to pull all the nodes that belong to `group 12345`, I just need to query all records that `parentId = 12345` | |
If I want to patch a node info, I can patch directly to the `o-node` service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment