Annotation Details
FirebaseCollection()
Annotate a class with @FirebaseCollection()
.
If no parameter is provided, then the class name is taken as the Collection name.
If a parameter (of type string) is provided, then the parameter value is taken as Collection Name For e.g.
@FirebaseCollection('StudentCollection')
class Student{
}
In this case the firebase collection is created with name: StudentCollection
DocumentKey()
Annotate a property with @DocumentKey()
This property is used as the key of the document. Specify the key type with one of the following values:
- User defined Key: The key is defined by the user.
- Auto Generated Key: The key is automatically generated by Firebase
- Auto Incremented Key: An auto incrementing key is generated by Firebase
Read more about document keys.
DocumentField
Annotate a property with @DocumentField
If any property is NOT annotated with this annotation, this field will NOT be saved in the document. This gives users the flexibility to skip some fields which are not to be saved in documents.
StorageFile
Annotate a property with @StorageFile
Properties annotated like this will be considered as storage file. They will be uploaded into the Storage bucket.
The fields should be of type: jugnu.Types.StorageFile
The type definition is as follows:
interface StorageFile{
name: String, // Name of file
uri: String // The file path
}
DocumentArrayField
If there is an array of other entities, then declare it using the DocumentArrayField
.
Pass the entity name to the decorator so that the framework can understand the underlying entity object and its annotations.
@DocumentArrayField(InvoicePayment)
payments: InvoicePayment[];
AutoIncrement
Annotate a property with @AutoIncrement
Properties annotated like this will be auto incremented at the time of create. Jugnu will create a collection to keep a track of current counter and will incremente the value automatically.
SystemAdminData
Annotate a property with @SystemAdminData
Only one property can be annotated with this. The property should be of type jugnu.Types.SystemAdminData
.
The type definition is as follows:
interface SystemAdminData{
createdBy?: any,
createdAt?: Date,
changedBy?: any,
changedAt?: Date
}
If any property is annotated like this, Jugnu will set the values automatically at the time of creation.