{
  "meta": {
    "$_GET": [
      {
        "type": "text",
        "name": "offset"
      },
      {
        "type": "text",
        "name": "limit"
      },
      {
        "type": "text",
        "name": "sort"
      },
      {
        "type": "text",
        "name": "dir"
      },
      {
        "type": "text",
        "name": "search"
      },
      {
        "type": "text",
        "name": "collection_type"
      }
    ]
  },
  "exec": {
    "steps": [
      {
        "name": "",
        "module": "auth",
        "action": "restrict",
        "options": {
          "provider": "security",
          "permissions": [
            "Active"
          ]
        }
      },
      {
        "name": "records",
        "module": "dbconnector",
        "action": "paged",
        "options": {
          "connection": "db",
          "sql": {
            "type": "select",
            "columns": [
              {
                "table": "collections",
                "column": "name"
              },
              {
                "table": "collections",
                "column": "id"
              },
              {
                "table": "collections",
                "column": "collectiontype_id"
              },
              {
                "table": "collection_type",
                "column": "name",
                "alias": "collection_type"
              }
            ],
            "params": [
              {
                "operator": "contains",
                "type": "expression",
                "name": ":P1",
                "value": "{{$_GET.search}}",
                "test": ""
              },
              {
                "operator": "contains",
                "type": "expression",
                "name": ":P2",
                "value": "{{$_GET.search}}",
                "test": ""
              },
              {
                "operator": "equal",
                "type": "expression",
                "name": ":P3",
                "value": "{{$_GET.collection_type}}",
                "test": ""
              }
            ],
            "table": {
              "name": "collections"
            },
            "primary": "id",
            "joins": [
              {
                "table": "collection_type",
                "column": "*",
                "type": "INNER",
                "clauses": {
                  "condition": "AND",
                  "rules": [
                    {
                      "table": "collection_type",
                      "column": "id",
                      "operation": "=",
                      "operator": "equal",
                      "value": {
                        "table": "collections",
                        "column": "collectiontype_id",
                        "type": "number"
                      }
                    }
                  ]
                },
                "primary": "id"
              }
            ],
            "query": "select `collections`.`name`, `collections`.`id`, `collections`.`collectiontype_id`, `collection_type`.`name` as `collection_type` from `collections` inner join `collection_type` on `collection_type`.`id` = `collections`.`collectiontype_id` where (`collections`.`name` like ? or `collection_type`.`name` like ?) and (`collections`.`collectiontype_id` = ?)",
            "wheres": {
              "condition": "AND",
              "rules": [
                {
                  "condition": "OR",
                  "rules": [
                    {
                      "id": "collections.name",
                      "field": "collections.name",
                      "type": "string",
                      "operator": "contains",
                      "value": "{{$_GET.search}}",
                      "data": {
                        "table": "collections",
                        "column": "name",
                        "type": "text",
                        "columnObj": {
                          "type": "string",
                          "maxLength": 50,
                          "primary": false,
                          "nullable": false,
                          "name": "name"
                        }
                      },
                      "operation": "LIKE"
                    },
                    {
                      "id": "collection_type.name",
                      "field": "collection_type.name",
                      "type": "string",
                      "operator": "contains",
                      "value": "{{$_GET.search}}",
                      "data": {
                        "table": "collection_type",
                        "column": "name",
                        "type": "text",
                        "columnObj": {
                          "type": "string",
                          "maxLength": 50,
                          "primary": false,
                          "nullable": false,
                          "name": "name"
                        }
                      },
                      "operation": "LIKE"
                    }
                  ],
                  "conditional": "{{$_GET.search}}"
                },
                {
                  "condition": "AND",
                  "rules": [
                    {
                      "id": "collections.collectiontype_id",
                      "field": "collections.collectiontype_id",
                      "type": "double",
                      "operator": "equal",
                      "value": "{{$_GET.collection_type}}",
                      "data": {
                        "table": "collections",
                        "column": "collectiontype_id",
                        "type": "number",
                        "columnObj": {
                          "type": "reference",
                          "primary": false,
                          "nullable": false,
                          "references": "id",
                          "inTable": "collection_type",
                          "referenceType": "integer",
                          "onUpdate": "RESTRICT",
                          "onDelete": "RESTRICT",
                          "name": "collectiontype_id"
                        }
                      },
                      "operation": "="
                    }
                  ],
                  "conditional": "{{$_GET.collection_type}}"
                }
              ],
              "conditional": null,
              "valid": true
            }
          }
        },
        "output": true,
        "meta": [
          {
            "name": "offset",
            "type": "number"
          },
          {
            "name": "limit",
            "type": "number"
          },
          {
            "name": "total",
            "type": "number"
          },
          {
            "name": "page",
            "type": "object",
            "sub": [
              {
                "name": "offset",
                "type": "object",
                "sub": [
                  {
                    "name": "first",
                    "type": "number"
                  },
                  {
                    "name": "prev",
                    "type": "number"
                  },
                  {
                    "name": "next",
                    "type": "number"
                  },
                  {
                    "name": "last",
                    "type": "number"
                  }
                ]
              },
              {
                "name": "current",
                "type": "number"
              },
              {
                "name": "total",
                "type": "number"
              }
            ]
          },
          {
            "name": "data",
            "type": "array",
            "sub": [
              {
                "type": "text",
                "name": "name"
              },
              {
                "type": "number",
                "name": "id"
              },
              {
                "type": "number",
                "name": "collectiontype_id"
              },
              {
                "type": "text",
                "name": "collection_type"
              }
            ]
          }
        ],
        "outputType": "object"
      }
    ]
  }
}