Closed zaosoula closed 4 days ago
Hello @zaosoula
Can you please share what use-cases we are trying to serve by adding the meta
property to relationships?
@thetutlage Hi, we use meta to define the options of editable field for the frontend, it allow use to automaticaly generate view, and forms based on the model
import { BaseModel, column, manyToMany } from '@adonisjs/lucid/orm'
import { compose } from '@adonisjs/core/helpers'
import { Filterable } from 'adonis-lucid-filter'
import ProductFilter from '#filters/product_filter'
import { CommonModel } from '#mixins/common_model'
import { EntityModel } from '#mixins/entity_model'
import User from '#models/user'
import ProductCategory from './product_category.js'
import type { ManyToMany } from '@adonisjs/lucid/types/relations'
export default class Product extends compose(
BaseModel,
Filterable,
CommonModel({ userModel: User }),
EntityModel({ userModel: User })
) {
static $filter = () => ProductFilter
@column({
meta: {
label: 'Nom',
type: 'text',
summary: true,
},
})
declare name: string
@column({
meta: {
label: 'RΓ©current',
type: 'checkbox',
summary: true,
},
})
declare isRecurrent: boolean
@manyToMany(() => ProductCategory, {
meta: {
label: 'CatΓ©gories',
type: 'autocomplete',
options: {
resource: 'product-category',
label: 'name',
},
summary: true,
},
})
declare categories: ManyToMany<typeof ProductCategory>
}
Thanks π
π Linked issue
β Type of change
π Description
Add the
meta
property to relations like on classic column to convey additional data for third party librariesπ Checklist