Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
protogrid:json_api_database_views [2021-09-16 11:29] druprotogrid:json_api_database_views [2023-01-10 23:16] (current) – [Standard Views Decommissioned With Version 2.6.0] dru
Line 3: Line 3:
 A Database View can be seen as a table with two columns. The first column is called 'key', the second one is called 'value'. The keys have to be unique. A lookup to a view always expects a key, several keys or a range of keys. The response of a lookup consists of all requested keys together with their values. Example for respond: A Database View can be seen as a table with two columns. The first column is called 'key', the second one is called 'value'. The keys have to be unique. A lookup to a view always expects a key, several keys or a range of keys. The response of a lookup consists of all requested keys together with their values. Example for respond:
  
-<code json>+<code javascript>
 { {
   "errors": [],   "errors": [],
-  "protogrid_environment_version": "1.4.10", 
   "result": {   "result": {
     "rows": [     "rows": [
Line 36: Line 35:
  
 For details about listings / views and how to request it, please see section about view [[protogrid:api_endpoints|endpoints]]. Please note that all views have the Card id as the last key component due to how Protogrid is implemented on top of CouchDB. In most cases it is useful to specify the start_key and end_key URL parameters with null and {} (empty object) as their last element. This will give all keys matching the other specified keys. For details about listings / views and how to request it, please see section about view [[protogrid:api_endpoints|endpoints]]. Please note that all views have the Card id as the last key component due to how Protogrid is implemented on top of CouchDB. In most cases it is useful to specify the start_key and end_key URL parameters with null and {} (empty object) as their last element. This will give all keys matching the other specified keys.
 +
 +For newcomers: In 90% of use cases, the [[#by_proto_and_design_element_and_value_and_sortstring_and_id|"by_proto_and_design_element_and_value_and_sortstring_and_id"]] view fits best.
  
 ===== Protogrid Standard Views ===== ===== Protogrid Standard Views =====
Line 50: Line 51:
  
 Example respond: Example respond:
-<code json>+<code javascript >
 { {
   "errors": [],   "errors": [],
-  "protogrid_environment_version": "1.4.10", 
   "result": {   "result": {
     "next_card_key": [     "next_card_key": [
Line 59: Line 59:
     ],     ],
     "rows": [     "rows": [
-    +      
-      "key":+        "key":
-        "4d523d95-31dd-4cb3-b60a-c974404e4ffd" +          "4d523d95-31dd-4cb3-b60a-c974404e4ffd" 
-      ], +        ], 
-      "value": null+        "value": null
       },       },
       ...       ...
-      ] +    ]
-    }+
   }   }
 +}
 </code> </code>
    
Line 82: Line 82:
  
 Example respond (be aware, that this Card is a System Card and therefore looks different to the typical Cards): Example respond (be aware, that this Card is a System Card and therefore looks different to the typical Cards):
-<code json>+<code javascript >
 { {
     "errors": [],     "errors": [],
-    "protogrid_environment_version": "1.4.14", 
     "result": {     "result": {
         "next_card_key": [         "next_card_key": [
Line 199: Line 198:
  
 === by_sortstring_and_id === === by_sortstring_and_id ===
- 
-=== by_search_term_and_sortstring_and_id === 
-This view contains Cards for a certain search term by id. The key is composed of the search term, the Card sorting string and the Card key. Search term means a specific string, for which you want to find all Cards containing this string in the values. You may not find Cards having this string only in the labels of the fields. Example: 
-<code json> 
-["behavior", "ScriptLibrary:Server-ScriptLibrary Next Steps", "1475e62a-47d7-4a29-98c2-c89f50edd497"] 
-</code> 
-The value is null. 
- 
-**Be aware**: The search only goes over values stored in this Card. This may differ from the visual representation Card. For example when Card A references another Card, you see the Shortname of the referenced Card (say "wishes an offer") in the corresponding relation field. Nevertheless, the Card only stores the Card key of the related Card (say "c18bc1c2-5499-49cc-90e0-f06b4af1474f"), therefore you will not find Card A when searching for Cards containing "wishes". 
- 
-Example request to find all cards containing the word "behavior": 
-<code> 
-https://example.protogrid.com/api/v2/apps/produktekatalog/views/by_search_term_and_sortstring_and_id?start_key=["behavior", null, null]&end_key=["behavior", {}, {}] 
-</code> 
- 
-Example response: 
-<code json> 
-{ 
-    "errors": [], 
-    "protogrid_environment_version": "1.4.14", 
-    "result": { 
-        "next_card_key": [ 
-            "behavior", 
-            "ScriptLibrary:Server-ScriptLibrary Products", 
-            "ba9859e1-68ad-4004-b8e0-c4f0812edf20" 
-        ], 
-        "rows": [ 
-            { 
-                "key": [ 
-                    "behavior", 
-                    "ScriptLibrary:Server-ScriptLibrary Next Steps", 
-                    "1475e62a-47d7-4a29-98c2-c89f50edd497" 
-                ], 
-                "value": null 
-            }, 
-            { 
-                "key": [ 
-                    "behavior", 
-                    "ScriptLibrary:Server-ScriptLibrary Next Steps", 
-                    "1475e62a-47d7-4a29-98c2-c89f50edd497" 
-                ], 
-                "value": null 
-            }, 
-            { 
-                "key": [ 
-                    "behavior", 
-                    "ScriptLibrary:Server-ScriptLibrary Products", 
-                    "ba9859e1-68ad-4004-b8e0-c4f0812edf20" 
-                ], 
-                "value": null 
-            }, 
-            ... 
-        ] 
-    } 
-} 
-</code> 
- 
-You might have duplicates in the code due to several occurrences of the same search term on the same Card. 
  
 === by_design_element_and_sortstring_and_id === === by_design_element_and_sortstring_and_id ===
Line 269: Line 210:
 Example request to get all Cards, where the name (in my example having with fieldkey "816950eb-1b70-41e2-89f5-5400f9636345") starts with "n" or "o": Example request to get all Cards, where the name (in my example having with fieldkey "816950eb-1b70-41e2-89f5-5400f9636345") starts with "n" or "o":
 <code> <code>
-https://example.protogrid.com/api/v2/apps/produktekatalog/views/by_design_element_and_value_and_sortstring_and_id?start_key=["816950eb-1b70-41e2-89f5-5400f9636345", "n", null, null]&end_key=["816950eb-1b70-41e2-89f5-5400f9636345", "m", {}, {}]+https://example.protogrid.com/api/v2/apps/produktekatalog/views/by_design_element_and_value_and_sortstring_and_id?start_key=["816950eb-1b70-41e2-89f5-5400f9636345","n",null,null]&end_key=["816950eb-1b70-41e2-89f5-5400f9636345","m",{},{}]
 </code> </code>
  
 Example response: Example response:
-<code json>+<code javascript >
 { {
     "errors": [],     "errors": [],
-    "protogrid_environment_version": "1.4.14", 
     "result": {     "result": {
         "rows": [         "rows": [
Line 309: Line 249:
 Example Request to get all Cards belonging to the Proto with key "12532072-0d76-4457-8cf8-7847d0470738": Example Request to get all Cards belonging to the Proto with key "12532072-0d76-4457-8cf8-7847d0470738":
 <code> <code>
-https://example.protogrid.com/api/v2/apps/produktekatalog/views/by_proto_and_sortstring_and_id?start_key=["12532072-0d76-4457-8cf8-7847d0470738", null, null]&end_key=["12532072-0d76-4457-8cf8-7847d0470738", {}, {}]+https://example.protogrid.com/api/v2/apps/produktekatalog/views/by_proto_and_sortstring_and_id?start_key=["12532072-0d76-4457-8cf8-7847d0470738",null,null]&end_key=["12532072-0d76-4457-8cf8-7847d0470738",{},{}]
 </code> </code>
  
Line 315: Line 255:
  
 Example respond: Example respond:
-<code json>+<code javascript >
 { {
     "errors": [],     "errors": [],
-    "protogrid_environment_version": "1.4.14", 
     "result": {     "result": {
         "rows": [         "rows": [
Line 334: Line 273:
 } }
 </code> </code>
- 
-=== by_proto_and_search_term_and_sortstring_and_id === 
-This view contains all non-deleted and non-hidden Cards by proto and searchterm (see also [[#by_search_term_and_sortstring_and_id|by_search_term_and_sortstring_and_id]]. Therefore the key is composed of the Proto key, the searchterm, the Card sorting string and the Card key. Example: 
-<code> 
-["9c2bdd7d-05bd-4d16-8339-11116e737b3a", "wants", "Priscilla Molesworth - wishes an offer - Luxor 600t", "21f28df9-b0fd-431d-a773-5c6f58ff94a2"] 
-</code> 
- 
-Example Request to get all Cards of Proto "9c2bdd7d-05bd-4d16-8339-11116e737b3a" containing the string "wants": 
-<code> 
-https://example.protogrid.com/api/v2/apps/produktekatalog/views/by_proto_and_search_term_and_sortstring_and_id?start_key=["9c2bdd7d-05bd-4d16-8339-11116e737b3a", "wants", null, null]&end_key=["9c2bdd7d-05bd-4d16-8339-11116e737b3a", "wants", {}, {}] 
-</code> 
- 
-Example response: 
-<code json> 
-{ 
-    "errors": [], 
-    "protogrid_environment_version": "1.4.14", 
-    "result": { 
-        "rows": [ 
-            { 
-                "key": [ 
-                    "9c2bdd7d-05bd-4d16-8339-11116e737b3a", 
-                    "wants", 
-                    "Priscilla Molesworth - wishes an offer - Luxor 600t", 
-                    "21f28df9-b0fd-431d-a773-5c6f58ff94a2" 
-                ], 
-                "value": null 
-            }, 
-            ... 
-        ] 
-    } 
-} 
-</code> 
- 
  
 === by_proto_and_design_element_and_sortstring_and_id === === by_proto_and_design_element_and_sortstring_and_id ===
Line 380: Line 285:
 Example Request to find all Cards based on Proto "12532072-0d76-4457-8cf8-7847d0470738" whos price ("ed2c109d-a825-4b97-a0bb-31c13185408d") lies between 400 and 500: Example Request to find all Cards based on Proto "12532072-0d76-4457-8cf8-7847d0470738" whos price ("ed2c109d-a825-4b97-a0bb-31c13185408d") lies between 400 and 500:
 <code> <code>
-https://example.protogrid.com/api/v2/apps/produktekatalog/views/by_proto_and_design_element_and_value_and_sortstring_and_id?start_key=["12532072-0d76-4457-8cf8-7847d0470738","ed2c109d-a825-4b97-a0bb-31c13185408d", "400", null, null]&end_key=["12532072-0d76-4457-8cf8-7847d0470738", "ed2c109d-a825-4b97-a0bb-31c13185408d", "500", {}, {}]+https://example.protogrid.com/api/v2/apps/produktekatalog/views/by_proto_and_design_element_and_value_and_sortstring_and_id?start_key=["12532072-0d76-4457-8cf8-7847d0470738","ed2c109d-a825-4b97-a0bb-31c13185408d","400",null,null]&end_key=["12532072-0d76-4457-8cf8-7847d0470738","ed2c109d-a825-4b97-a0bb-31c13185408d","500",{},{}]
 </code> </code>
  
 Example response: Example response:
-<code json>+<code javascript >
 { {
     "errors": [],     "errors": [],
-    "protogrid_environment_version": "2.0beta7", 
     "result": {     "result": {
         "rows": [         "rows": [
Line 419: Line 323:
 === deleted_by_sortstring_and_id === === deleted_by_sortstring_and_id ===
 This view contains the IDs of all the deleted Cards as keys. The value is null. The request and response are analog to view [[#by_sortstring_and_id|"by_sortstring_and_id"]]. This view contains the IDs of all the deleted Cards as keys. The value is null. The request and response are analog to view [[#by_sortstring_and_id|"by_sortstring_and_id"]].
- 
-=== deleted_by_search_term_and_sortstring_and_id === 
-This view contains all deleted Cards for a certain search term by id. The value is null. The request and response are analog to view [[#by_search_term_and_sortstring_and_id|"by_search_term_and_sortstring_and_id"]]. 
  
 === deleted_by_design_element_and_sortstring_and_id === === deleted_by_design_element_and_sortstring_and_id ===
Line 433: Line 334:
 === related_keys_by_id === === related_keys_by_id ===
 This view contains all Cards by id. The value contains the related keys. This view contains all Cards by id. The value contains the related keys.
- 
-**Be aware**: This is one of the very few views, where the key is **NOT** surrounded by "[ ... ]"! 
  
 Example request to find all Cards related to the Card "234486c7-939f-49f4-88b2-6fd51369a1d9": Example request to find all Cards related to the Card "234486c7-939f-49f4-88b2-6fd51369a1d9":
 <code> <code>
-https://example.protogrid.com/api/v2/apps/produktekatalog/views/related_keys_by_id?keys=["234486c7-939f-49f4-88b2-6fd51369a1d9"]+https://example.protogrid.com/api/v2/apps/produktekatalog/views/related_keys_by_id?keys=[["234486c7-939f-49f4-88b2-6fd51369a1d9"]]
 </code> </code>
  
 Example response: Example response:
-<code json>+<code javascript >
 { {
     "errors": [],     "errors": [],
-    "protogrid_environment_version": "1.4.15", 
     "result": {     "result": {
         "rows": [         "rows": [
             {             {
-                "key": "234486c7-939f-49f4-88b2-6fd51369a1d9",+                "key": 
 +                    "234486c7-939f-49f4-88b2-6fd51369a1d9" 
 +                ],
                 "value": [                 "value": [
                     [                     [
Line 499: Line 399:
 Example request to find all Cards relating to the (Related) Card with key "626f04f7-179d-40d7-99f0-9e54343abf98": Example request to find all Cards relating to the (Related) Card with key "626f04f7-179d-40d7-99f0-9e54343abf98":
 <code> <code>
-https://example.protogrid.com/api/v2/apps/produktekatalog/views/relating_cards_by_related_key_and_id?start_key=["626f04f7-179d-40d7-99f0-9e54343abf98", null]&end_key=["626f04f7-179d-40d7-99f0-9e54343abf98", {}]+https://example.protogrid.com/api/v2/apps/produktekatalog/views/relating_cards_by_related_key_and_id?start_key=["626f04f7-179d-40d7-99f0-9e54343abf98",null]&end_key=["626f04f7-179d-40d7-99f0-9e54343abf98",{}]
 </code> </code>
  
 Example response: Example response:
-<code json>+<code javascript >
 { {
     "errors": [],     "errors": [],
-    "protogrid_environment_version": "1.4.15", 
     "result": {     "result": {
         "rows": [         "rows": [
Line 560: Line 459:
  
 Example response: Example response:
-<code json>+<code javascript >
 { {
     "errors": [],     "errors": [],
-    "protogrid_environment_version": "1.4.15", 
     "result": {     "result": {
         "rows": [         "rows": [
             {             {
-                "key": "5f12ccf6-9de0-4796-d366-106e4b7b8af9",+                "key": 
 +                    "5f12ccf6-9de0-4796-d366-106e4b7b8af9" 
 +                ],
                 "value": {                 "value": {
                     "#": [                     "#": [
Line 608: Line 508:
 </code> </code>
  
- +=== shortname_objects_by_id === 
-=== shortname_by_language_objects_by_id === +This view contains all Cards which contain shortname data by id. The value contains the shortnames by language.
-This view contains all Cards which contains shortname data by id. The value contains the shortnames by language.+
  
 Example request to get the shortnames of the Card with key "a0e6717f-c613-404a-bc08-a090311c651c": Example request to get the shortnames of the Card with key "a0e6717f-c613-404a-bc08-a090311c651c":
 <code> <code>
-https://example.protogrid.com/api/v2/apps/produktekatalog/views/shortname_by_language_objects_by_id?keys=[["a0e6717f-c613-404a-bc08-a090311c651c"]]+https://example.protogrid.com/api/v2/apps/produktekatalog/views/shortname_objects_by_id?keys=[["a0e6717f-c613-404a-bc08-a090311c651c"]]
 </code> </code>
  
 Example response: Example response:
-<code json>+<code javascript >
 { {
     "errors": [],     "errors": [],
-    "protogrid_environment_version": "1.4.15", 
     "result": {     "result": {
         "rows": [         "rows": [
             {             {
-                "key": "a0e6717f-c613-404a-bc08-a090311c651c",+                "key": 
 +                    "a0e6717f-c613-404a-bc08-a090311c651c" 
 +                ],
                 "value": {                 "value": {
                     "de": "Priscilla Molesworth - wishes an offer",                     "de": "Priscilla Molesworth - wishes an offer",
Line 635: Line 535:
 } }
 </code> </code>
- 
- 
  
 ===== Views of Dedicated Search Dialog Boxes ===== ===== Views of Dedicated Search Dialog Boxes =====
 It is also possible to access the views of dedicated [[protogrid:TableView#Search Dialog Boxes|Search Dialog Box]] from the JSON API. Just use the Card ID of the Search Dialog Box as view name. It is also possible to access the views of dedicated [[protogrid:TableView#Search Dialog Boxes|Search Dialog Box]] from the JSON API. Just use the Card ID of the Search Dialog Box as view name.
 +
 +Hint: For straight forward API usage in most cases it is recommended to use Search Dialog Boxes in "Simple Keys in JSON API only" display mode.
 +
 +Please note that Datetime Fields in Dedicated Search Boxes are indexed slightly differently than in normal views: If the date-time value is configured as a fixed filter field, the time component will always be set to 0 (example: "2021-11-11T00:00:00.000Z"). If the date-time value is configured as a sort field or filter field with range (greater/less than option enabled), the time portion is left as it is (example: "2021-11-11T22:22:00.000Z").
  
 Example Request: Example Request:
Line 647: Line 549:
  
 The key depends on the individually configured Filter Fields for the acessed Search Dialog Box. The key depends on the individually configured Filter Fields for the acessed Search Dialog Box.
 +
 +===== Change Log =====
 +==== Standard Views Decommissioned With Version 2.1.5 ====
 +  * by_id_and_value
 +  * by_proto_and_search_term_and_id
 +  * by_search_term_and_id
 +  * data_protos_by_id
 +  * data_protos_by_search_term_and_id
 +  * datetime_field_definitions_by_id
 +  * datetime_field_definitions_by_search_term_and_id
 +  * deleted_by_design_element_and_value_and_id
 +  * deleted_by_id
 +  * deleted_by_search_term_and_id
 +  * logs_by_time_and_id
 +  * navroot_candidates_by_design_element_and_value_and_id
 +  * navroot_candidates_by_id
 +  * navroot_candidates_by_search_term_and_id
 +  * number_field_definitions_by_id
 +  * number_field_definitions_by_search_term_and_id
 +  * relational_definitions_by_id_and_related_proto
 +  * text_field_definitions_by_id
 +  * text_field_definitions_by_search_term_and_id
 +
 +==== Standard Views Decommissioned With Version 2.2.1 ====
 +  * by_design_element_and_value_and_id
 +  * by_proto_and_id
 +  * by_proto_and_design_element_and_value_and_id
 +  * deleted_by_proto_and_design_element_and_value_and_id
 +  * navroot_candidates_by_design_element_and_sortstring_and_id
 +  * navroot_candidates_by_design_element_and_value_and_sortstring_and_id
 +  * sums_by_proto_and_design_element
 +  * sums_by_proto_and_design_element_and_condition
 +  * datetime_field_definitions_by_sortstring_and_id
 +  * datetime_field_definitions_by_search_term_and_sortstring_and_id
 +  * text_field_definitions_by_sortstring_and_id
 +  * text_field_definitions_by_search_term_and_sortstring_and_id
 +  * number_field_definitions_by_sortstring_and_id
 +  * number_field_definitions_by_search_term_and_sortstring_and_id
 +  * all_protos_by_id
 +  * all_agents_by_id
 +  * all_connectors_by_url_name
 +
 +==== Adjustments to Views With Version 2.2.2 ====
 +  - All views: If a view is requested with the "descending" parameter set to true "start_key" and "end_key" must now be exchanged.
 +  - All views: All string values as well as sortstrings are now cut off after 300 characters.
 +  - All views: The separator between human readable values and keys is now "\u0009" instead of "\u9999".
 +  - All views: The second last column "sortstring" is now indexed in a shorter manner: "<SORTSTRING>" instead of "<PROTO KEY>\u9999<SORTSTRING>\u9999<CARD KEY>"
 +  - Dedicated Search Boxes: Now all filters must be set. An empty filter field in a Search Dialog Boxes now means a filter for those Cards where the target field is also empty.
 +  - Dedicated Search Boxes: Datetime Fields in Dedicated Search Boxes are now indexed slightly differently than in normal views: If the date-time value is configured as a fixed filter field, the time component will always be set to 0 (example: “2021-11-11T00:00:00.000Z”). If the date-time value is configured as a sort field or filter field with range (greater/less than option enabled), the time portion is left as it is (example: “2021-11-11T22:22:00.000Z”).
 +  - Dedicated Search Boxes with "sortable" display mode: Columns are now indexed in a shorter manner:
 +    * For Relation/Tag Field values: "< SORTSTRING >\u0009<KEY>" instead of "<SORTSTRING>\u9999<KEY>\u9999<KEY>"
 +    * For other field values: "<VALUE>" instead of "\u9999<VALUE>\u9999<VALUE>"
 +    * Note: It is anyway recommended to use Search Dialog Boxes with display mode “Simple Keys in JSON API only” (i. e. non-sortable).
 +  - In views "by_design_element_and_sortstring_and_id", "by_proto_and_design_element_and_sortstring_and_id" and "deleted_by_design_element_and_sortstring_and_id" the design element's sortstrings are now indexed in a shorter manner:
 +    * For Relation/Tag Field values: "< SORTSTRING >\u0009<KEY>" instead of "<SORTSTRING>\u9999<KEY>\u9999<KEY>"
 +    * For other field values: "<VALUE>" instead of "\u9999<VALUE>\u9999<VALUE>"
 +    * Note: If you don't explicitly need sorting by design element value is anyway recommended to use the views "by_design_element_and_value_and_sortstring_and_id", by_proto_and_design_element_and_value_and_sortstring_and_id"" or "deleted_by_design_element_and_value_and_sortstring_and_id".
 +  - In views "by_design_element_and_sortstring_and_id", "by_proto_and_design_element_and_sortstring_and_id" and "deleted_by_design_element_and_sortstring_and_id" there is a new column for the Card's sortstring after the design element's sortstring. Example:
 +    * View columns of "by_design_element_and_sortstring_and_id" before: ["816950eb-1b70-41e2-89f5-5400f9636345", "nightTable 2.0", "9a5f37ab-30a7-4c91-b99f-f573a1c7d1b9"]
 +    * View columns of by_design_element_and_sortstring_and_id"" now: ["816950eb-1b70-41e2-89f5-5400f9636345", "nightTable 2.0", "nightTable 2.0 - furniture", "9a5f37ab-30a7-4c91-b99f-f573a1c7d1b9"]
 +
 +==== Standard Views Decommissioned With Version 2.6.0 ====
 +  * by_search_term_and_sortstring_and_id
 +  * by_proto_and_search_term_and_sortstring_and_id
 +  * deleted_by_search_term_and_sortstring_and_id
 +  * navroot_candidates_by_sortstring_and_id
 +  * navroot_candidates_by_search_term_and_sortstring_and_id
 +  * data_protos_by_sortstring_and_id
 +  * data_protos_by_search_term_and_sortstring_and_id
Print/export