@teikei/api
Version:
Teikei API server. Teikei is the software that powers ernte-teilen.org, a website that maps out Community-supported Agriculture in Germany.
50 lines (46 loc) • 1.11 kB
JavaScript
import { BaseModel } from '../base'
export default class Farm extends BaseModel {
static tableName = 'farms'
// eslint-disable-next-line class-methods-use-this
type() {
return 'Farm'
}
static relationMappings = {
ownerships: {
relation: BaseModel.ManyToManyRelation,
modelClass: `${__dirname}/users`,
join: {
from: 'farms.id',
through: {
from: 'farms_users.farm_id',
to: 'farms_users.user_id'
},
to: 'users.id'
}
},
places: {
relation: BaseModel.ManyToManyRelation,
modelClass: `${__dirname}/depots`,
join: {
from: 'farms.id',
through: {
from: 'farms_depots.farm_id',
to: 'farms_depots.depot_id'
},
to: 'depots.id'
}
},
products: {
relation: BaseModel.ManyToManyRelation,
modelClass: `${__dirname}/products`,
join: {
from: 'farms.id',
through: {
from: 'farms_products.farm_id',
to: 'farms_products.product_id'
},
to: 'products.id'
}
}
}
}