How to rename xid in Jsondata
-
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:
- 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 NameChange to:
ID XID
36 Address- 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>- 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.
-
Hi Felicia,
- 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;
-
No it is not possible currently.
-
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?
-
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 -
Hi Felicia,
I'm still not sure I understand. Why couldn't you use the XID field in the manner you are describing?