SomeFire commented on a change in pull request #8245: URL: https://github.com/apache/ignite/pull/8245#discussion_r490185735
########## File path: docs/_docs/restapi.adoc ########## @@ -240,6 +243,69 @@ Similarly, the `get` command with `keyType=int` and `valueType=date` would be: http://[host]:[port]/ignite?cmd=get&key=1&cacheName=myCache&keyType=int&valueType=date ---- +=== Custom user defined types + +For custom objects, the JSON format is used. For example, we can work with the following object using the REST API: +[source, javascript] + { + "uid": "7e51118b-eb15-4373-b57f-4984cb9cd7ac", + "name": "John Doe", + "organization": 5678901, + "married": false, + "salary": 156.1 + } + +The following request puts this object into the cache named 'testCache' as a value with a type name `Person` and a key `1`. + + http://[host]:[port]/ignite?cacheName=testCache&cmd=put&keyType=int&key=1&valueType=Person&val=%7B%0A+++++%22uid%22%3A+%227e51118b-eb15-4373-b57f-4984cb9cd7ac%22%2C%0A+++++%22name%22%3A+%22John+Doe%22%2C%0A+++++%22organization%22%3A+5678901%2C%0A+++++%22married%22%3A+false%2C%0A+++++%22salary%22%3A+156.1%0A++%7D& + +On the server side, the JSON value from this request will be converted to link:/docs/data-modeling/data-modeling#binary-object-format[binary object]. Field types are resolved in the following order: + +* If the type name is a `Java class` available on the server, the class field types with corresponding names will be used for resolving JSON object field types. +* If the type name is of a `query entity` type, the field types will be resolved according to the field type defined in the `query entity`. +* Otherwise, the field types will be resolved according to regular JSON types. + +For example, if there is no definition of the "Person" type on the server, the fields will be converted in accordance with the standard JSON types: +[source, javascript] +"uid": "7e51118b-eb15-4373-b57f-4984cb9cd7ac", // string +"name": "John Doe", // string +"organization": 5678901, // int +"married": false, // boolean +"salary": 156.1 // double + +If the `query entity` is set Review comment: ```suggestion If the `query entity` is set, query fields will be filled with given values. ``` ########## File path: docs/_docs/restapi.adoc ########## @@ -240,6 +243,69 @@ Similarly, the `get` command with `keyType=int` and `valueType=date` would be: http://[host]:[port]/ignite?cmd=get&key=1&cacheName=myCache&keyType=int&valueType=date ---- +=== Custom user defined types + +For custom objects, the JSON format is used. For example, we can work with the following object using the REST API: +[source, javascript] + { + "uid": "7e51118b-eb15-4373-b57f-4984cb9cd7ac", + "name": "John Doe", + "organization": 5678901, + "married": false, + "salary": 156.1 + } + +The following request puts this object into the cache named 'testCache' as a value with a type name `Person` and a key `1`. + + http://[host]:[port]/ignite?cacheName=testCache&cmd=put&keyType=int&key=1&valueType=Person&val=%7B%0A+++++%22uid%22%3A+%227e51118b-eb15-4373-b57f-4984cb9cd7ac%22%2C%0A+++++%22name%22%3A+%22John+Doe%22%2C%0A+++++%22organization%22%3A+5678901%2C%0A+++++%22married%22%3A+false%2C%0A+++++%22salary%22%3A+156.1%0A++%7D& + +On the server side, the JSON value from this request will be converted to link:/docs/data-modeling/data-modeling#binary-object-format[binary object]. Field types are resolved in the following order: + +* If the type name is a `Java class` available on the server, the class field types with corresponding names will be used for resolving JSON object field types. +* If the type name is of a `query entity` type, the field types will be resolved according to the field type defined in the `query entity`. +* Otherwise, the field types will be resolved according to regular JSON types. + +For example, if there is no definition of the "Person" type on the server, the fields will be converted in accordance with the standard JSON types: +[source, javascript] +"uid": "7e51118b-eb15-4373-b57f-4984cb9cd7ac", // string +"name": "John Doe", // string +"organization": 5678901, // int +"married": false, // boolean +"salary": 156.1 // double + +If the `query entity` is set +[source,xml] + <bean class="org.apache.ignite.cache.QueryEntity"> + <property name="keyType" value="java.lang.Integer"/> + <property name="valueType" value="Person"/> + <property name="fields"> + <map> + <entry key="uid" value="java.util.UUID"/> + <entry key="name" value="java.lang.String"/> + <entry key="organization" value="java.lang.Long"/> + <entry key="married" value="java.lang.Boolean"/> + <entry key="salary" value="java.lang.Float"/> + </map> + </property> + </bean> + +or Java class "Person" is loaded on the server. Review comment: ```suggestion If Java class "Person" is loaded on the server, class fields will be filled with given values. ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
