From 09818f425c61337db7cd1e1e1d32a4a59a47b339 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sun, 11 Sep 2022 22:01:42 +0200 Subject: [PATCH] add note about selecing specific columns --- CONTRIBUTING.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9a42fdf04..d1dc494da 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -270,6 +270,12 @@ const users = userIds.length > 0 ? await Users.find({ }) : []; ``` +### typeorm: selecting only specific columns + +If you select specific columns of a table only, you will probably not be able to use the usual `getOne`, `getMany` etc. +Instead you might want to try using `getRawOne` and `getRawMany`. +For that, you may also want to add aliases to the columns you select, which can be done using the second parameter of `select` or `addSelect`. + ### Array indexing in SQL PostgreSQL array indices **start at 1**.