Open mbnoimi opened 3 years ago
@mbnoimi, I realized that I couldn't simply create the repository using lb4 repository
command, because the User
model has a hasOne
relationship with UserCredentials
.
I deleted the User and UserCredentials models and repository classes (and make sure you update the index.ts files). And it's working fine.
Trying to remember what I was doing when writing the tutorial... I think I probably just copied the user models for the database migration script to run.
It should be working after you deleted the model and repository files.
testdb=# select * from public.user;
id | realm | username | email | emailverified | verificationtoken
--------------------------------------+-------+----------+--------------------+---------------+-------------------
5cf29c80-b2c3-4b17-bef7-4dd76021bcd5 | | | testuser1@test.com | |
(1 row)
testdb=# select * from public.usercredentials;
id | password | userid
--------------------------------------+--------------------------------------------------------------+----------------------------------
----
a9e80afb-f251-479c-8a86-1c91e2bbe373 | $2a$10$am49HadqPQXKboXpZ9QQre79VFoftYGOSX0DzC5gW76djjWfudfIy | 5cf29c80-b2c3-4b17-bef7-4dd76021b
cd5
(1 row)
It should be working after you deleted the model and repository files.
Still doesn't work. May you please make a commit for the correction you've suggested!
I pushed my changes that produced this result in branch https://github.com/dhmlau/loopback4-example-todo-jwt-db/tree/delete-artifacts.
I pushed my changes that produced this result in branch https://github.com/dhmlau/loopback4-example-todo-jwt-db/tree/delete-artifacts.
Still doesn't work! What I did:
$ git name-rev --name-only HEAD
remotes/origin/delete-artifacts
$
pds.datasource.ts
for the proper config
testdb
npm run rebuild
npm run migrate
npm start
/signup
then got this error:
Server is running at http://[::1]:3000
WARNING: relational database doesn't support {strict: false} mode. {strict: true} mode will be set for model User instead.
Request POST /signup failed with status code 500. error: relation "public.user" does not exist
at Parser.parseErrorMessage (/home/laptop/loopback4-example-todo-jwt-db/node_modules/pg-protocol/dist/parser.js:278:15)
at Parser.handlePacket (/home/laptop/loopback4-example-todo-jwt-db/node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (/home/laptop/loopback4-example-todo-jwt-db/node_modules/pg-protocol/dist/parser.js:39:38)
at Socket.<anonymous> (/home/laptop/loopback4-example-todo-jwt-db/node_modules/pg-protocol/dist/index.js:10:42)
at Socket.emit (events.js:315:20)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
at Socket.Readable.push (internal/streams/readable.js:223:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
^C
$
IMPORTANT:
Step #5 only generates todo
table
For step 4, can you run npm run build
instead?
Step #5 only generates todo table
yes. from the error you've shown, it looks like user
table doesn't exist.
For step 4, can you run npm run build instead?
I did it to be sure there is no old files (from master
brunch) will affect on the new build.
yes. from the error you've shown, it looks like user table doesn't exist.
May you modify the code to fix this issue?
@mbnoimi, I'm using the master
branch to create the table.
If you take my repo (master branch) and make it to connect to your database, were you able to create the table?
@mbnoimi, I'm using the
master
branch to create the table. If you take my repo (master branch) and make it to connect to your database, were you able to create the table?
Still doesn't work! What I did:
$ git name-rev --name-only HEAD
master
$
pds.datasource.ts
for the proper config
testdb
npm run build
npm run migrate
(generated two tables)
npm start
/signup
then got this error:
Server is running at http://[::1]:3000
WARNING: relational database doesn't support {strict: false} mode. {strict: true} mode will be set for model User instead.
Request POST /signup failed with status code 500. TypeError: this.userRepository.userCredentials is not a function
at UserController.signUp (/home/laptop/loopback4-example-todo-jwt-db/dist/controllers/user.controller.js:73:35)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async /home/laptop/loopback4-example-todo-jwt-db/node_modules/@loopback/rest/dist/providers/invoke-method.provider.js:37:32
at async /home/laptop/loopback4-example-todo-jwt-db/node_modules/@loopback/express/dist/middleware-interceptor.js:82:25
at async /home/laptop/loopback4-example-todo-jwt-db/node_modules/@loopback/express/dist/middleware-interceptor.js:82:25
at async /home/laptop/loopback4-example-todo-jwt-db/node_modules/@loopback/rest/dist/providers/send.provider.js:39:32
at async MySequence.handle (/home/laptop/loopback4-example-todo-jwt-db/node_modules/@loopback/rest/dist/sequence.js:201:9)
at async HttpHandler._handleRequest (/home/laptop/loopback4-example-todo-jwt-db/node_modules/@loopback/rest/dist/http-handler.js:64:9)
^C
$
Hello,
Whenever I try to call
/signup
I get the following error message: