1.0.1 • Published 4 years ago
icql-dba-tags v1.0.1
ICQL DBA Tags
Table of Contents generated with DocToc
Tag Expressions (tagexes)
- Add a tag by prefixing a tagname with a plus sign:
+fancy,+global,+web - Remove a tag by prefixing a tagname with a minus sign (a hyphen):
-fancy,-global,-web. This is called a subtractive tag expression. - Add a value by adding a
:colon followed by a JSON literal:+weight:"100kg" - Prefixing a value-less tagex with a minus as in
-tagis equivalent to writing+tag:false, prefixing it with a plus as in+tagis equivalent to writing+tag:true. - Subtractive tags cannot have explicit values, so
-tag:falseor-tag:trueor whatever will cause an error. - There is a table
t_tagsthat registers all known tags alongside with their fallback values.
Usage
Instantiation
fallbacks: true: when retrieving tags for an ID, pre-poulate the returned object with the tags' fallback values, but leave out fallback values that arefalse. The most frequent use case is thought to be the one where one has a fair number of tags, most of which only apply to a small-ish subset of IDs. One will want to set the fallback value for all these tags tofalseand associate tags selectively where they positively do apply. Then, when retrieving tags withfallbacks: true, an object will be returned with only the explicit tags set as keys, and the implicitlyfalseones left out. This being JavaScript, accessingtags.fooon an objecttags = { bar: true, }will result inundefined, which is a falsey value.fallbacks: 'all': likefallbacks: truebut does include even those fallback values that arefalse. When retrieving tags withfallbacks: 'all', the resulting object will always contain all registered tags with their effective values.fallbacks: false: (default) do not pre-populate the returned object of tag values.
Data Structure
- Tags get associated with single IDs or ranges of IDs
- IDs are defined to be integers, can index anything, or stand for themselves (e.g. repreent Unicode code points)
- In the API, use keys
loandhito define the first and the last ID to become associated with a tag; set onlylo(and leavehiunset,undefinedornull) to associate a tag with a single ID. This will be modelled by auto-settinghitolo, resulting in a a range with a single ID.
API
To Do
- documentation
- allow to set fallback handling at instantiation time