• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    How to rename xid in Jsondata

    Mango Automation general Discussion
    2
    4
    1.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      Felicia Luong
      last edited by

      I had copied the following script from API Docs>Directives>ma-json-store and tried it.

      <ma-json-store xid="phoneData" item="myItem" value="myValue"></ma-json-store>
      <input ng-model="myValue.phone">
      <md-button class="md-raised md-primary md-hue-3" ng-click="myItem.$save()">
      <md-icon>save</md-icon> Save
      </md-button>
      <p>Phone # from JSON store: {{myItem.jsonData.phone}}</p>

      I realized that each time I rename XID to a different name, a different ID is created in jsondata. I detected this when I used SQL to query out the data from Jsondata using this script "select * from jsondata".

      Question:

      1. How to I rename XID to a different name without deleting ID?

      For example, Jsondata may give an ID of 36 with XID "Name". I want to change the ID 36 XID from "Name" to "Address" without deleting ID 36.

      Current:
      ID XID
      36 Name

      Change to:
      ID XID
      36 Address

      1. For the above script, is it possible to ID instead XID? Does the following script work? I had tried but failed. Perhaps I had missed out something.

      <ma-json-store id="36" item="myItem" value="myValue"></ma-json-store>
      <input ng-model="myValue.phone">
      <md-button class="md-raised md-primary md-hue-3" ng-click="myItem.$save()">
      <md-icon>save</md-icon> Save
      </md-button>
      <p>Phone # from JSON store: {{myItem.jsonData.phone}}</p>

      1. For ID, is it possible to assign the number manually instead of letting system to generate ID? If yes, how can I do it?

      Thanks.

      1 Reply Last reply Reply Quote 0
      • phildunlapP
        phildunlap
        last edited by

        Hi Felicia,

        1. Can you explain some of why you are wanting to work with the IDs directly? Certainly one can change the ID through the SQL console, running
        UPDATE jsonData SET xid='Address' WHERE id=36;
        
        1. No it is not possible currently.

        2. The ID is a normal autoincrement column and primary key. So, while it is possible to assign any unique integer, the database server prefers that you do not, since it is tracking what the next ID is in the information schema tables, and it simplifies the database's job to let it manage the uniqueness of the keys without having to query anything. I am not sure offhand if manually setting the ID to the value of the next ID in the information schema for the table will throw an error or not, but I cannot think of a good reason to do this. If you are trying to encode information into the number, why wouldn't you be encoding that information into the XID instead and working with the XIDs?

        1 Reply Last reply Reply Quote 0
        • F
          Felicia Luong
          last edited by

          Hi Phildunlap,

          Thanks for the prompt reply.

          Basically, I will be using XID to do some naming which may be very lengthy. Therefore, I am thinking using ID instead since it is just numeric & short. Just want to see if it is possible.

          Regards,
          Felicia

          1 Reply Last reply Reply Quote 0
          • phildunlapP
            phildunlap
            last edited by

            Hi Felicia,

            I'm still not sure I understand. Why couldn't you use the XID field in the manner you are describing?

            1 Reply Last reply Reply Quote 0
            • First post
              Last post