Comments and answers for "Command documents vs documents"https://forum.predix.io/questions/13554/command-documents-vs-documents.html
The latest comments and answers for the question "Command documents vs documents"Comment by Ravi on Ravi's answerhttps://forum.predix.io/comments/13615/view.html
Thanks for your reply,
After command document is saved to device, command document consists list of id,type,userid and users in request body. If i want to fetch all the users from the document, should it be read from request body or there is any other way of getting all the users from the document without referring to request body.Fri, 14 Oct 2016 10:40:35 GMTRaviAnswer by clifton.craig@ge.comhttps://forum.predix.io/answers/13576/view.html
Hi @Ravi,
You could send all of the users you wish to add in one command if your command processor supports it. A command like the following could be written via the CDB service which would then be sent to the micro service:
{
"_id":"COMMAND_ADD_COMMENT_"+ userID+"_"+ Date.now(), //unique Id of the command
"type": "command", // command router expect type should be 'command'
"~userid": userID, // userID for person who created the command
"channels": ["entity_" + userID, "users"], // channels
"~status": "pending", // command-processing state: pending => processed || error
"request": { // router request
"uri": "/command/add_users", // uri for command-processor
"method": "PUT", // always set to PUT
"headers": {}, // headers to include in request to command-processor
"body": {"Bob", "Sue", "Luanne", "Mark"} // body of request
}
}
Your micro service would receive the body as an HTTP POST and could update the users in your system accordingly. Once the call completes the status of the command document would be updated from "pending" to "processed". This update would be visible on the mobile device and you could subscribe to document change notifications to let your JavaScript based web app know when the update finished. The assuming your user updates are written to the mobile service, the updated data would automatically sync to the mobile device and the users could be read either individually or in bulk via the CDB service.
Please let us know if this clarifies things and/or answers your questions. Thanks and feedback is always welcome.Thu, 13 Oct 2016 16:21:57 GMTclifton.craig@ge.com