A Kurier addon that creates intermediate resource types for many-to-many relationships.
Install it using npm or yarn:
$ npm i -D @kurier/addon-many-to-many
$ yarn add -D @kurier/addon-many-to-many
Add it to your Kurier app:
import ManyToManyAddon from "@kurier/addon-many-to-many";
// ...
app.use(ManyToManyAddon);
Apply the addon to any resource relationship by setting the manyToMany
flag to true
:
import { Resource } from "kurier";
import Designer from "./designer";
export default class Collection extends Resource {
static schema = {
attributes: {
name: String,
slug: String,
},
relationships: {
designers: {
type: () => Designer,
manyToMany: true,
foreignKeyName: "design_id",
},
},
};
}
MIT