Warm tip: This article is reproduced from serverfault.com, please click

Directus calculated field / column

发布于 2020-11-27 18:30:16

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!

Questioner
Steve
Viewed
0
RANGER 2020-11-28 08:45:07

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