Custom Fields

Out of the box, Nova has three main collections: Posts, Users, and Comments. Each of them has a pre-set schema, but that schema can also be extended with custom fields.

For example, this is how the nova:newsletter package extends the Posts schema with a scheduledAt property that keeps track of when a post was sent out as part of an email newsletter:

1
2
3
4
5
6
7
Posts.addField({
fieldName: 'scheduledAt',
fieldSchema: {
type: Date,
optional: true
}
});

The collection.addField() function takes either a field object, or an array of fields. Each field has a fieldName property, and a fieldSchema property.

Each field schema supports all of the SimpleSchema properties, such as type, optional, etc.

A few special properties (insertableBy, editableBy, control, and order) are also supported by the Forms package.

You can also remove a field by calling collection.removeField(fieldName). For example:

1
Posts.removeField('scheduledAt');
Edit on GitHub