J
J
Jedi2018-10-30 05:47:07
Node.js
Jedi, 2018-10-30 05:47:07

Where is the best and most competent way to place a file that connects to the database?

Good morning!
I have a problem... I don't know where it would be more correct to place the file that connects to the meringue data.
The directory structure is as follows:

-src
--middleware
---errorHandler.js
---routes.js

--models
--- Тут модели для подключения и выполнения операций CRUD c определенными таблицами.

--modules

---auth
----auth.js (тут роуты "/auth", который импортируется в routes.js)

---user
----user.js (тут роуты "/users", который импортируется в routes.js)

---car
----car.js (тут роуты "/cars", который импортируется в routes.js)

--services

--index.js (app.js)
--config.js (файл конфигурации)

I used to just use mysql , but now I decided to use an ORM, namely the bookshelfjs library/package .
Tell me, please, where exactly is it better to save the connection file, where is the most logical? The purpose of the question is to implement everything correctly.
Thank you very much in advance!)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question