Skip to content
Advertisement

Directus calculated field / column

I’m building an app where companies pay a regular subscription. This gives them a detailed listing on our web site and a number of other (real world) benefits. When their subscription has expired, their listing will display with fewer details until they pay again.

I’m using Directus as the back end, and Vue.js as the front end. I want to have as little “business logic” in the Vue front end as possible.

The MySQL table DDL for the company is

create table company
(
    id               int(11) unsigned auto_increment primary key,
    name             varchar(200) not null comment 'name of company',
    description      text not null,
    address          text null comment 'company physical address'
    web_site         varchar(200) not null,
    ... many other fields
    subscription_expires datetime,
    created_on       datetime null,
    modified_on      datetime null,
)
    charset = utf8mb4;

I want to create a number of MySQL calculated fields: for example a company.show_details field that is false if subscription_expires is null or subscription_expires < now(), or company.needs_update true if modified_on > 24 months ago. This will make the Vue render logic very clean / obvious.

I can’t see a way to create calculated fields via Directus or to have them sync via the mysql schema. Is there documentation somewhere?

thanks!

Advertisement

Answer

I believe this is still a Feature Request for Directus. Perhaps upvote it to give it more traction?

https://github.com/directus/directus/discussions/3079

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement