エラー解決wiki - calm1205/flea-market-nestjs GitHub Wiki

postgresのselect文で1 row

select * from user;のsqlで(1 row)としか表示されない。

postgresにはschemaというdbを区分けするための概念が存在する。

そのため通常はselect * from schema_name.table_name;としなければならない。

以下のコマンドでschemaを設定することで毎回schemaを指定しなくても良くなる。

set search_path = schema_name;
select * from item;

しかし、なぜかテーブル名がuserの場合は例外なのかschemaをテーブル名の前につけないと検索結果の詳細表示ができない。

postgres=# set search_path = public;
postgres=# select * from user;
-[ RECORD 1 ]--
user | postgres

postgres=# select * from public.user;
-[ RECORD 1 ]----------------------------------
id       | ab4639e6-9126-4304-9224-b76e789d037d
username | nick
password | password
status   | FREE

docker on node で bcrypt

Error: /usr/src/app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header

macOS上でインストールしたbcryptはdocker上で動かない。

解決策

  1. localでbcryptをアンインストール
  2. docker上でbcryptをインストール
  3. .dockerignoreを作成しnode_modulesを追記
docker compose exec node bash
# npm install --save bcrypt
# npm install --save-dev @types/bcrypt
# touch .dockerignore

.dockerignore

node_modules

typeormのschema変更をmigrationで検知できない

root@377e229d526d:/usr/src/app# npx typeorm migration:generate -n add_relation
No changes in database schema were found - cannot generate a migration. To create a new empty migration use "typeorm migration:create" command

解決策

ビルドが必要

npm run build