logo

该视频仅会员有权观看

立即开通课程「Node 框架 Express 实践」权限。

¥
199
/ 年

改造调取内容列表用的功能

  • Define and export an interface named get post options future above the get post function in the post service.
  • Describe options parameter for get post with a filter property in the interface.
  • The filter contains properties: name (string), sql (string), and prime (string) for naming, expressing, and providing values for filter conditions, respectively.
  • Add a filter property of type get post options future to get post options.
  • In the get post function, destructure the future property from options.
  • Declare a sql parameter to provide values for sql placeholders during query execution.
  • Initialize an empty array proms with type any[] to hold any type of data.
  • Set the sql parameter based on existence of prime in future, converting its value to an array including existing prime values.
  • Add other parameters to primes for pagination later on.
  • Incorporate where condition using sql from future in the query.
  • Execute the query by providing values for placeholders using the prepared primes.