Record Types

Together with fields, record types form the backbone of your data.

The following settings can be defined:

  • Meta Data Like the name and description
  • Storage Adapter What's the default location the data is read and write from
  • Access Control Who can edit which record types
  • Fields Which fields are part of the record type

Protip: You can add custom meta data to it yourself to influence the behaviour in various parts of the app.


Create a new file Product.js in the @/plugins/custom/record-types directory,

import defineRecordType from '@/lib/record-type/defineRecordType.js'

export default defineRecordType({
    id: 'product',
    name: 'Product',
    adapter: 'mongodb',
    acl: {
        'role:creator': 'write',
        'role:editor': 'write',
        'role:viewer': 'read',
    },
    fields: {
        name: {
            type: 'text'
        },
        base_price: {
            description: 'Price for which we purchase the product',
            type: 'currency',
            acl: {
                'role:editor': 'none',
                'role:viewer': 'none',
            }
        },
        list_price: {
            type: 'currency'
        },
    }
})

Then within the @/plugins/custom/record-types/index.js

import Product from './Product'

export default ([
    Product,
])

The record types are registered within @/plugins/custom/register.js

import definePlugin from '@/lib/module/definePlugin'
import recordTypes from './record-types'

export default definePlugin({
    recordTypes
})

FAQ

What is the naming convention for record type ID's?

  • The file name can be anything apart from the ID.
  • The ID is used to refer to the table / collection name.
  • The ID is used as slug when visiting the Record Overview / Detail Pages.

Roadmap

  • explain how acl works on record level