You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can add examples like this for each chapter, or is there something else I should illustrate?
README.md
..........
Map all queries to an entity
Now, let's map the results of all queries to Album class.
models/Album/index.ts
import{createModel,mapWithEntity}from"pgtyped-model"import{pool}from"./connection"import*asqueriesfrom"./Album.queries"// Return type of all queries will change to `Album[]`.exportconstAlbumModel=createModel({
queries,connection: pool,camelCaseColumnNames: true,collectDefault: mapWithEntity(Album),})
Each query from the original SQL file will be exposed as a function with return type Album[].
Yes, that will be great in my opinion.
Showing a snippet of the queries file would probably also make sense, for those unfamiliar with pgTyped.
That way, one can fully trace the lifecycle of the query query definition -> model definition -> usage.
The README has plenty of details on how to build models, but no examples of how to use/call them after they have been built.
The text was updated successfully, but these errors were encountered: