bytesandbutter / pg-crud

a postgresql crud layer
MIT License
1 stars 0 forks source link

get view definition #3

Open qwesda opened 10 years ago

qwesda commented 10 years ago

GET "/invoices/_definition"

{
  "columns" : {
    "gdid"            : {"type" : "int", "isPrimaryKey" : true, "sortable" : true, "filterable" : true},
    "status"          : {"type" : "enum", "filterable" : true},
    "contact"         : {"type" : "json", "filterable" : true},

    "total"           : {"type" : "money", "sortable" : true, "filterable" : true },
    "date_due"        : {"type" : "date",  "sortable" : true, "filterable" : true },
    "date_payment"    : {"type" : "date",  "sortable" : true, "filterable" : true },

    "account_number"  : {"type" : "text", "filterable" : true},
    "bank_code"       : {"type" : "text", "filterable" : true},
    "IBAN"            : {"type" : "text", "filterable" : true},
    "BIC"             : {"type" : "text", "filterable" : true},
    "name"            : {"type" : "text", "filterable" : true},
    "label"           : {"type" : "text", "filterable" : true},
  }
}
ibotty commented 10 years ago

implemented with a different format. as the list of columns might be different for every action, it uses the following format. still missing is filterable, sortable, etc.

{
    "path": "/invoices/:invoices_id",
    "list": {
        "allowed": [
            "name", 
            "date_due", 
            "label", 
            "bic", 
            "iban", 
            "account_number", 
            "bank_code", 
            "total", 
            "date", 
            "date_due", 
            "date_payment", 
            "status", 
            "contact"
        ]
    }, 
    "primary_key": [
        "gdid"
    ], 
    "read": {
        "allowed": [
            "name", 
            "date_due", 
            "label", 
            "bic", 
            "iban", 
            "account_number", 
            "bank_code", 
            "total", 
            "date", 
            "date_due", 
            "date_payment", 
            "status", 
            "contact", 
            "positions"
        ]
    }
}
ibotty commented 10 years ago

oh, it is under /invoices/_document. that is likely to change to support documentation for multi-column pks...

what about /_definition/ and just list all the resource definitons there?

qwesda commented 10 years ago

/_definition is fine by me

Daniel Schwarz dan@butter.sh http://pgp.mit.edu/pks/lookup?op=get&search=0x1586760D7DBEDE3F

On 10 Oct 2014, at 17:10, Tobias Florek notifications@github.com wrote:

oh, it is under /invoices/_document. that is likely to change to support documentation for multi-column pks...

what about /_definition/ and just list all the resource definitons there?

— Reply to this email directly or view it on GitHub.

ibotty commented 10 years ago

summarizing the phone call, we have below _meta/definition a e.g. the following json.

{
  "shops": {
    "path": "/shops/:shops_id",
    "primary key": ["shops_id"],
    "read": {
      "shops_id": { "type": "unspecified" },
      ...
    },
    "list": {
      "shops_id": { "type": "unspecified", "sortable": true, "filerable": true },
      ...
    },
    "subresources": {
      "release_formats" : { format as seen above }
    }
  }
}