Is it possible to use an associated model’s property as a title in Adminjs?

Background

I have an app for game collecting. In this context, the properties of the game itself are not necessarily important. Instead, we really care about the actual different releases of an individual game. We might have a PS4 version or an Xbox version, or we might have a European version vs. a Japanese version.

So, I have a couple of Sequelize models like this (truncated/modified for brevity):

const Game = sequelize.define('Game', {
    title: { type: DataTypes.STRING },
});

const Release = sequelize.define('Release', {
    region: { type: DataTypes.STRING },
    platform: { type: DataTypes.STRING },
    releaseDate: { type: DataTypes.Date },
});

And of course later I associate them…

Release.belongsTo(Game);
Game.hasMany(Releases);

This all works great! Everything in the app is going swimmingly.

The Problem

I wanted to a way to modify data in my app without directly accessing the database, but before I’d actually finished every single CRUD route in my app. So I went with AdminJS, hoping it would be similar to something like Django Admin.

When going to add a Release to another object, however (like a User Collection) the options are the IDs of the individual records. These are not helpful at all and don’t mean anything. Ok, great, it looks like AdminJS automatically looks for things like name or title to use here.

So, my first thought was to add a Sequelize Virtual field to cover this:

title: {
    type: DataTypes.VIRTUAL,
    get() {
        // uh-oh
    }
}

And here we run into a problem. None of the fields of this object uniquely identify it! The thing that uniquely identifies it is composite with the Game object.

What I Want

What I would like to happen, is that the title of a Release is something like: ${this.Game.title} ${this.platform} ${this.region} and that I can choose that from a drop-down when creating new records.

However, as far as I know, it is not possible to have access to the associated record here. I can’t use a Promise to actually load the associated record in the get function (not that I think I’d want to, that would cause mandatory n+1 issues or worse?) and so my expectation is that this won’t be something in Sequelize, but rather AdminJS.

I have looked through the documentation on Properties and Resources and don’t really see anything for changing what’s actually being displayed at all. There are options for sorting and visibility and so on, which are useful, but not what I’m trying to do.

I have also searched question after question here and elsewhere about getting related models in a Sequelize Model get function, but most of them remain unanswered. (Or just simply list model.Model.property as if it works?)

So my question is:

Is this possible? Can I have an AdminJS Title composed of another record’s property?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật