Closed Jcbobo closed 7 years ago
You can always use the native loopback Model events to track operations that have to do with the DB. I also added some events here that might help. Other than that i can't think of anything else
that's great, do you have the time to provide some example?
check the event bus here https://loopback.io/doc/en/lb2/Events.html
As for the mixin
app.on('lbTree.add.success', function(node){
console.log(node)
})
so putting all together i can use the normal "save/update" event for handle the data replication and the evento of the tree for the tree operation, perfect thanks you
@mbouclas after this modification calling the addNode method (from the explorer) give a validation error (parent is required) also if is passed
{ "error": { "statusCode": 400, "name": "Error", "message": "parent is a required argument", "stack": "Error: parent is a required argument\n" }
curl
curl -X PUT --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' -d 'parent=%7B%22id%22%3A%20%2258c6b762189b4e1b380e0394%22%7D&node=%7B%20%20%20%20%20%22name%22%3A%20%22WWWWWWWWW%22%20%20%20%20%20%20%20%20%20%7D' 'http://localhost:3050/api/tests/addNode'
for design reason i should handle a situation a little "strange"
each time an entry is added to the local collection i need to replicate the entire collection test in the test-local collection (adding exstra information and manipulating some fields) each time an entry in the test collection is modified (basically on the tree structure) i need to update accordly the tree structure in test-local
if I understand correcly i can use the "create" nodes for handling the replication and when i need to update the tree structure (basically each time the moveNode) is called i retreave the test-local node (replicated from test node that i moved), retreate the test-local node (replicated from the test node where i'm moving) and call a moveNode accordly on the "test-local" collection,
there is some nice way to handle that? what is coming to my mind is, custom event (node created, node moved, node deleted)
if you have have some idea that can "simplify" my job will be great