informatics-isi-edu / ermrestjs

ERMrest client library in JavaScript
Apache License 2.0
4 stars 3 forks source link

Allow changing column level annotations on Catalog, schema, or table #971

Closed RFSH closed 1 year ago

RFSH commented 1 year ago

We should introduce a new annotation that can be defined on Catalog, schema, or table to change the behavior of columns.

The following is how this annotation would look like. This allows defining all column level annotations on upper levels by just specifying their types or names.

"tag:isrd.isi.edu,2023:column-defaults": {
  "by_name": {
    "<name>": {
      "<annot_key>": {}
    }
  },
  "by_type": {
    "<type>": {
      "<annot_key>": {}
    }
  }
}

This will satisfy both #939 and #877. We can use the by_name property to change the display settings of system columns, and by_type would allow changing the format of all timestamp columns.

The following is an example of using this annotation:

"tag:isrd.isi.edu,2023:column-defaults": {
  "by_name": {
    "RCT": {
      "tag:misd.isi.edu,2015:display": {
        "name": "Creation time",
        "comment": "When the record was recorded."
      }
    }
  },
  "by_type": {
    "timestamp": {
      "tag:isrd.isi.edu,2016:column-display": {
        "*": {
          "pre_format": {
            "format": "YYYY-MM-DD"
          }
        }
      }
    }
  }
}