Skip to content

Overview

CAUTION

Any preferences lookup is cached immediately (!), unless options.noCache=true

Preferences are used to retrieve settings by an arbitrary key. There are fallback and (document) local preferences. These are called global preferences.

Also, a single user may have an override to a single setting of a preference. Those are called user preferences.

A single fallback location of System Preferences (f.id: 50c9b51e-f477-48c0-94a9-b1445b287fd7) can be used to provide fallback preferences. Local preferences are looked up to the nearest ancestor with a matching preference child.

Active preferences

A preference needs to have the field activeSettings or defaultUserSettings defined or it will be ignored.

User preferences

With each preference call, global and user preferences are looked up. A user setting takes precedence over a global setting, but only if the field has some value.

User preferences are always belonging to a single user (via created.by).

Examples

javascript
// fallback
const isEnabled = await Aeppic.Preferences.getSetting('some-namespace:my-preference:enabled')


// local, with possible fallback
const document = await Aeppic.get('some-uuid')
const isEnabled = await Aeppic.Preferences.getSettingForDocument('some-namespace:my-preference:enabled', document)

Notes

Namespaces are required currently.