[{"data":1,"prerenderedAt":104},["ShallowReactive",2],{"legacy-question-563d56684f6de273ba93a9667423e801":3,"legacy-question-author-koji-kadoma":77,"legacy-question-category-website-building":93},{"id":4,"title":5,"author":6,"body":7,"category":64,"date":65,"description":5,"extension":66,"locale":67,"meta":68,"navigation":69,"path":70,"seo":71,"slug":72,"stem":73,"tag":74,"updated":65,"__hash__":76},"legacyQuestions\u002F20210902010000-Cockpit CMSで他のコレクションとリレーションするには？.md","Cockpit CMSで他のコレクションとリレーションするには？","koji-kadoma",{"type":8,"value":9,"toc":60},"minimark",[10,15,19,28,31,34,45,48,54,57],[11,12,14],"h2",{"id":13},"collectionlinkを使います","Collectionlinkを使います",[16,17,18],"p",{},"Cockpit CMSでは他のコレクション（テーブル）と連携させるのは、フィールドタイプに「Collectionlink」を使います。",[16,20,21],{},[22,23,27],"a",{"href":24,"rel":25},"https:\u002F\u002Fgetcockpit.com\u002Fdocumentation\u002Freference\u002Ffieldtypes",[26],"nofollow","Fieldtypes",[16,29,30],{},"フィールドタイプに「Collectionlink」を使うと、エントリー編集画面で、リンクしたコレクションのデータを一覧から選択できるようになる他、リンクされたコレクションのエントリーからは、「どのエントリーとリンクされているか？」を確認できるようになります。",[16,32,33],{},"Collectionlinkを使うには、オプションJSONの項目で、どのコレクションとリンクするかなどを設定する必要があります。",[35,36,41],"pre",{"className":37,"code":39,"language":40},[38],"language-text","{\n  \"link\": \"makers\", \u002F\u002F リンクするコレクション\n  \"display\": \"name\", \u002F\u002F jsonで出力する際にどの項目を表示するか\n  \"multiple\": false, \u002F\u002F 複数選択可能にするか？（タグなどを想定）\n  \"limit\": false \u002F\u002F 件数を制限するか？\n}\n","text",[42,43,39],"code",{"__ignoreMap":44},"",[16,46,47],{},"リンクができると、そのエントリーの出力JSONに、リンクしたコレクションのデータが入ります。",[35,49,52],{"className":50,"code":51,"language":40},[38],"{\n  \"id\": \"1\",\n  \"title\": \"iPhone 12\",\n  \"maker_id\": {\n    \"_id\": \"6130b4c737393784d10000bd\",\n    \"link\": \"makers\",\n    \"display\": \"Apple (アップル)\"\n  },\n",[42,53,51],{"__ignoreMap":44},[16,55,56],{},"という形です。",[16,58,59],{},"静的サイトジェネレータのように、ジェネレータ側で処理を加える場合には設定しない方が使い勝手が良い可能性もありますが、SPAのようにヘッドレスCMSの内容をそのまま表示する場合には、必須の項目かと思います。",{"title":44,"searchDepth":61,"depth":61,"links":62},2,[63],{"id":13,"depth":61,"text":14},"website-building","2021-09-02T01:00:00.000Z","md","ja",{},true,"\u002F20210902010000-cockpit-cms",{"title":5,"description":5},"563d56684f6de273ba93a9667423e801","20210902010000-Cockpit CMSで他のコレクションとリレーションするには？",[75],"cockpit-cms","eDhqcZFQugKdsDxe8wUIYyCV2wDYgDG-gtT3SNsHXWY",{"id":78,"title":79,"body":80,"date":84,"description":85,"extension":66,"locale":67,"meta":86,"name":89,"navigation":69,"path":90,"seo":91,"slug":6,"stem":6,"updated":84,"__hash__":92},"legacyAuthors\u002Fkoji-kadoma.md","Koji Kadoma",{"type":8,"value":81,"toc":82},[],{"title":44,"searchDepth":61,"depth":61,"links":83},[],"2021-04-01T00:00:00.000Z","Webエンジニアです。Javascript、PHP、Ruby、Dockerなどをメインで使っています。",{"image":87,"url":88},"https:\u002F\u002Fwww.codit.work\u002Fimgs\u002Favatar\u002Fkoji-kadoma.png","https:\u002F\u002Fkoji.pages.dev\u002F",null,"\u002Fkoji-kadoma",{"title":79,"description":85},"H1yaGicrsv1CzYTbFeEXQosuYx93lIutD3_XwXMhAFk",{"id":94,"title":95,"body":96,"date":84,"description":95,"extension":66,"locale":67,"meta":100,"navigation":69,"path":101,"seo":102,"slug":64,"stem":64,"updated":84,"__hash__":103},"legacyCategories\u002Fwebsite-building.md","Webサイト構築",{"type":8,"value":97,"toc":98},[],{"title":44,"searchDepth":61,"depth":61,"links":99},[],{},"\u002Fwebsite-building",{"title":95,"description":95},"h9jPLD2mzMm3L4sFN5qWSiSirySQQLdnxLhQcvw8VlQ",1783320299777]