File tree Expand file tree Collapse file tree 2 files changed +14
-11
lines changed
examples/js/js-data_repository-06_db_connection_class/src Expand file tree Collapse file tree 2 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,17 @@ import {UsersSearcher} from "./UsersSearcher";
33import { MySqlConfig } from "./MySqlConfig" ;
44
55export class Container {
6- mysqlConfig = new MySqlConfig ( ) ;
7- mysqlUserRepository = new MySqlUserRepository ( this . mysqlConfig ) ;
6+ Mysql = require ( 'sync-mysql' ) ;
7+
8+ mysqlConfig = new MySqlConfig ( ) ;
9+ mySqlConnection = new this . Mysql ( {
10+ host : this . mysqlConfig . host ,
11+ user : this . mysqlConfig . user ,
12+ password : this . mysqlConfig . password ,
13+ database : this . mysqlConfig . database ,
14+ port : this . mysqlConfig . port
15+ } ) ;
16+
17+ mysqlUserRepository = new MySqlUserRepository ( this . mySqlConnection ) ;
818 usersSearcher = new UsersSearcher ( this . mysqlUserRepository ) ;
919}
Original file line number Diff line number Diff line change 11export class MySqlUserRepository {
2- constructor ( config ) {
3- const Mysql = require ( 'sync-mysql' ) ;
4- this . connection = new Mysql ( {
5- host : config . host ,
6- user : config . user ,
7- password : config . password ,
8- database : config . database ,
9- port : config . port
10- } ) ;
2+ constructor ( connection ) {
3+ this . connection = connection ;
114 }
125
136 searchAll ( ) {
You can’t perform that action at this time.
0 commit comments