engineerSoul github,https://github.com/vhjihuang/nestapp,按照文档敲代码,再敲到截图中的代码时报错了[upl-image-preview uuid=87438490-179c-47cf-8c62-a10352fdb7f1 url=https://cn-nb1.rains3.com/3rcd/2024-02-25/1708828680-132669-snipaste-chapter4.png fullscreen_uri={URL}]
Cloneable engineerSoul https://github.com/vhjihuang/nestapp/blob/main/src/modules/content/services/post.service.ts#L25 这句代码的报错原因有两个。第一是你的 buildListQuery 方法返回的不是 Promise,所以 await 是不需要的,课程中是因为 https://git.3rcd.com/classroom/courses/src/branch/main/data/docs/nestjs/chapter4.md?display=source#L1561 这句代码所以在调用 buildListQuery 方法时需要 await。第二是你在 PostService 中引用的 PostEntity 引用错误,具体参考 https://git.3rcd.com/classroom/nestjs/src/branch/content/src/modules/content/services/post.service.ts#L13 。 https://github.com/vhjihuang/nestapp/blob/main/src/modules/content/services/post.service.ts#L26 这里的错误是需要引入 paginate 方法,具体参考 https://git.3rcd.com/classroom/nestjs/src/branch/content/src/modules/content/services/post.service.ts#L8 。课程的代码块有时会缺少引用的具体信息,写代码时以仓库课程代码为准。 https://github.com/vhjihuang/nestapp/blob/main/src/modules/content/services/post.service.ts#L65 此处的参数 orderBy 类型应修改为 PostOrderType。
Cloneable engineerSoul 能理解你的想法,我的意思也是按文档学习,不过在文档中的代码部分,最好参考教程代码库中对应的代码,因为文档上有时候代码会拷贝有缺漏,教程代码库中的代码都是 pincman 自己运行测试过的,所以正确性比较有保障一些。