Predix_Logo
  • Categories
    • Questions
    • Predix | Updates
      • Pricing
      • Product
    • Deloitte - Private
    • How-To
    • Accenture-Private
  • Explore
    • Topics
    • Questions
    • Articles
    • Feedback or Feature Requests
  • Sign in
  • Home /
  • Questions /
avatar image
0
Question by Ravi · Oct 12, 2016 at 11:28 PM · pmmobile

Command documents vs documents

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.

Comment
Add comment
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
0

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.

Comment
Add comment · Show 1 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ravi · Oct 14, 2016 at 03:40 AM 0
Share

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.

Follow this Question

Answers Answers and Comments

49 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

When running my predix mobile Web app Im getting the following error Attempted to register service where service id is already associated with another service. ServiceId: location 3 Answers

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

GE Monogram
  • Legal
  • Cookies
  • Forum Terms
  • Contact Us
  • Copyright © 2017 General Electric Company. All rights reserved.


Enterprise
Social Q&A

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Submit your feedback or feature request
  • Categories
  • Questions
  • Predix | Updates
    • Pricing
    • Product
  • Deloitte - Private
  • How-To
  • Accenture-Private
  • Explore
  • Topics
  • Questions
  • Articles
  • Feedback or Feature Requests