Intro to annotations
In @romain.juban’s original example,
@db(versionHistory=true, archive=true) is an annotation. There is a set of types called “annotation” types, and they can all be applied to type metadata with the
@ symbol. There is a base type called
Annotation, and what I’m calling the “annotation” types is really just the set of types that are annotated with the
@annotation annotation .
What did you mean by “Ext.Db” and why doesn’t it work now?
In previous versions of the platform (v6 and below I believe), types were grouped / namespaced in modules. For backwards compatibility reasons and for some time after modules were removed (including platform version 7.2, the latest release at the time of my previous post), types were still assigned a fake module name (e.g.,
"-type-Metric" for the
Metric type), and the
c3ShowType utility still allowed you to pass a
"moduleName.TypeName" string argument to see type documentation. Several of the annotation types lived in an
Ext module, the
Db annotation type included. So
c3ShowType("Ext.Db") will work in v7.2, but module names must have been officially removed sometime since February.
So how do I see the documentation?
C3.annotation. For example, if I want to see the documentation for the
c3ShowType(Ts) would not work, but
c3ShowType(C3.annotation.Ts) would. The capitalization of annotation types may seem confusing—when applying an annotation, take the annotation type name, downcase the first letter and prepend
There’s also a helper function for locating an annotation type definition by name, which @henry.hsieh mentioned:
c3Annotation. It takes a
typeName string argument and returns a
Clarification on terminology
Some of the confusion comes from the terminology—“extension” and “annotation” have been used somewhat interchangeably in the past. “extension” comes from the function these types perform (extending metadata), and “annotation” comes from the form in which they’re applied to metadata (
The platform team is currently working on clearing up any potential confusion:
“extension” is changing to “annotation” to avoid confusion with “extends.”
Answers to specific questions
(All answers are equivalent)
Documentation for “treatment” in @ts
Documentation for “partitionKeyField” in @db
c3ShowType(C3.annotation.Annotation) for more details on how to write your own annotation type.