[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"$f5_AQa2a_Le0yAbPxuyzuRcjHko4mDvV2-l6yY_jt0Ac":3},{"code":4,"message":5,"data":6},200,"成功",{"id":7,"createdAt":8,"title":9,"content":10,"summary":11,"image":12,"uid":13,"user":14,"categoryId":21,"category":22,"subCategoryId":24,"subCategory":25,"comments":27,"status":17,"reason":12,"notice":12,"visitCount":28,"commentCount":29,"keywords":30},80,"2024-02-05T02:46:17.222Z","midwayjs在定义model的时候，外键的写法","比如这里有一个model，model中有一个外键关联另一个model：`HuntingRoles`，所以需要写外键关联。请注意foreignKey地方的注释，id和roleId的关系需要明了。\n```\n@ApiProperty({ description: '角色id' })\n  @ForeignKey(() => HuntingRoles)\n  @AllowNull(false)\n  @Column\n  roleId: number;\n\n  @BelongsTo(() => HuntingRoles, {\n    constraints: false,\n    foreignKey: \"roleId\",  // 这里一定是roleId，roleId是外键，如果写成”id”，那么就成了当前表的id对应的role\n  })\n  role: HuntingRoles;\n```\n\nforeignKey还可以写成下面的样子：\n```\n@BelongsTo(() => HuntingRoles,\"roleId\")\n  role: HuntingRoles;\n```","这里提示一下，在midwayjs中定义model的时候，外键的写法不要写错了。","",499668042977349,{"phone":15,"userId":13,"nickName":16,"vipType":17,"avatar":18,"sign":19,"createdAt":20},"13121171998","全栈老韩",1,"https://image.xinwei.ltd/images/IMG_5430.JPG","全栈工程师，擅长iOS App开发、前端（vue、react、nuxt、小程序&Taro）开发、Flutter、React Native、后端（midwayjs、golang、express、koa）开发、docker容器、seo优化等。","2024-01-01T16:14:30.305Z",2,{"id":21,"name":23},"IT技术",32,{"id":24,"name":26,"parentId":21},"前端",[],28,0,"midwayjs,midwayjs model,midwayjs表,midwayjs定义模型,midwayjs开发"]