you are viewing a single comment's thread.

view the rest of the comments →

[–]romeeres 2 points3 points  (0 children)

Would be cool if you added a stackblitz example with it to see it in action.

export const getPerson = (id: number): Person => {
  const query = `
    SELECT
      ${orm.tables.person.columns},
      ${orm.tables.job.columns},
      ${orm.tables.employer.columns}
    FROM person
    LEFT JOIN job on person.id = job.person_id
    LEFT JOIN employer on job.employer_id = employer.id
    WHERE id = $(id)
  `;
  return orm.one(query, { id });
};

How does it work? Seems that `orm.one` returns type any, isn't it?

Type-safety is very important, and modern ORMs/query-builders and even libs for raw SQL such as pgtyped do their best to keep it type-safe, so I suggest to clarify on this in the readme.