jhipster / generator-jhipster-nodejs

A NodeJS blueprint that creates the backend using NestJS
https://www.npmjs.com/package/generator-jhipster-nodejs
Apache License 2.0
256 stars 79 forks source link

how do i connect sql database ? #50

Closed ameinabdi closed 5 years ago

ameinabdi commented 5 years ago

How can read about sql db connection?

when i select mysql database i got this error to start project

Screenshot 2019-09-20 at 2 33 36 PM

ghost commented 5 years ago

Hi @ameinabdi, there is the orm.config.ts where is stored db information. For dev it will be always sqlite created on app startup.

ameinabdi commented 5 years ago

thanks @amanganiello90 i have added my info about database in that file but i still it doesn't work so did you test sql before now ?

ghost commented 5 years ago

What db have you choosen in the related question?

ameinabdi commented 5 years ago

mysql

ghost commented 5 years ago

What command are you using to startup application? Write in order the commands.

ameinabdi commented 5 years ago

jhipster --blueprint nodejs

ghost commented 5 years ago

That command is for generation.. I said about startup.. however for mysql prod db, the connection created is:

ormconfig = {
        name: 'default',
        type: 'mysql',
       url: 'mysql://localhost:27017/<your-app-name>,
        synchronize: true,
        logging: false,
        entities: [__dirname + '/domain/*.entity{.ts,.js}'],
    };

Change url with your mysql instance.

ameinabdi commented 5 years ago

i run this command inside the server folder npm start

ghost commented 5 years ago

i run this command inside the server folder npm start

Ok, so you are using sqlite dev db, not mysql.. paste in your server/src/orm.config.ts the orm.config.ts content

ameinabdi commented 5 years ago

but i don't need to use sqlite. i need to use mysql database

ghost commented 5 years ago

Then, replace in the if of Prod section the mysql source configuration and run:

set NODE_ENV=prod&&npm start

Please attention that in your db instance must be created the 3 user management tables, otherwise the initial db seed insert fails.

To disable it comment this line

ameinabdi commented 5 years ago

okey thanks a lot mr @amanganiello90