Hi all,
We use command documents for sending commands to command processor.For example we have 10 users data which need to be send to micro service that will attached as body in request field of command document. This command document will be stored with some id in the couch base lite.
Generally if we read the document with same ID, we will get the document with parameters like request, pending, type...., suppose if want to read just 10 users data, how it can be achieved.
Answer by clifton.craig@ge.com · Oct 13, 2016 at 09:21 AM
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.
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.
Error in running predix mobile app 1 Answer
Service Router in Predix Mobile SDK 1 Answer
Document notifier is not trigerred 2 Answers
Predix mobile app architecture 1 Answer