Skip to content

Schema

The active schema is edited directly in CMS interface (if permission is given), and is stored as a single document in Firestore.

Having the schema as a Firestore document, gives great flexibility in real-time syncing and allows for easy backups and replication.

Collections

Collections correspond directly to your Firestore collections, and will read/write documents directly from it.

Additional settings

PropertyTypeDescription
keystringName of the collection as used in Firestore.
labelstringAlias of collection used in overview.
fieldsarrayList of defined fields. See fields.
singletonbooleanMake singleton collection. See singletons.
createbooleanDetermine if creation should be permitted.
deletebooleanDetermine if deletion should be permitted.
exportbooleanFields to index for inline search.
timestampsbooleanAdds timestamps if enabled.
docLabelstringKey of the field used as label for the document.
searchstringKey of the field used for search in references.
sortBystringDefault key to sort by.
ascbooleanIf sort order should be assending.
dashboardobjectDefined dashboard for collection. See dashboards.
functionsarrayList of functions to extend form. See functions.

Fields

Your documents are defined using an array of fields of these types.

FieldExampleDescription
Text"Hello world"Simple text field.
Textarea"Long text"Long text field that adapt height to content.
Date"16-15-2004"Single date as string.
Time"13:37"Hours and minutes.
Timestamp16-15-2004-13:37Firestore timestamp.
Location{lat:"1", lng:"2", hash:"3"}Location object with calculated geo hash.
Geopoint[55.69° N, 13.37° E]Native Firestore geopoint.
Number666Number with optional step count.
Email"asd@asd.dk"Validated email.
Select"val1"Value from defined slect options.
Color"#b4d455"Native colorpicker with hex value.
Tags["yo", "wyd"]Array of uniqe stings.
HTML<p>hello</p>HTML content.
Image"https://storage.path/hash"Public URL from Firebase Storage.
BooleanfalseBoolean toggle.
Object{}Object that can contain individual fiels. Can also be colapsed.
File"https://storage.path/hash"Public URL from Firebase Storage.
References["path/to/doc"]Path to Firestore document.
MarkupN/AHTML only rendered in form.
Telephone"+45 33 99 88 22"String with formatted telephone number.

Sub collections

Sub collections are identical to collections, but are neasted under each document of the parent collection.

And yes, sub collections can have sub collections can have sub... etc.

Example
- myCollection
	- doc1
		- mySubCollection
	- doc2
		- mySubCollection
	- doc3
		- mySubCollection
			- subDoc 1
				- mySubSybCollection
			- subDoc 2
				- mySubSybCollection

Singletons

If a collection is marked as a singleton, each of it's children will corespond to a unique document instead of a collection.

This is ideal for creating f.ex. a settings collection.

Example
settings (singleton collection)
- colors (with uniqe fields)
- translations (with other uniqe fields)

Functions

Each collection form can be extended with custom callable cloud functions. These will appear at the bottom next to the save button.

An example of such function can be seen here:

js
import functions from 'firebase-functions'
import admin from 'firebase-admin'

export const getBTC = functions.region('europe-west1').https.onCall(async (docs, context) => {
	const btcPrice = await fetch('https://api.coinbase.com/v2/prices/btc-eur/buy').then((res) => res.json())
	for (let path of docs) {
		const doc = await admin.firestore().doc(path)
		doc.update({
			notes: `BTC is worth ${btcPrice.data.amount}${btcPrice.data.currency}`
		})
	}
	return {
		message: 'Doc has been updated with latest price!'
	}
})

Request

The function will get a request containing an array of document paths: ['collection/mydoc1'].

Currently this will only contain a single path to the document from where the function is called from. In the future this might be called on entire quries or collections.

Response

Multiple instructions can be sent as response.

js
// This will display an alert on the client
return {
	message: 'Thanks'
}

// This will redirect to a internal or external link
return {
	redirect: 'http://grid.ws'
}