Skip to content

Commit

Permalink
#12 add mysql-resource.
Browse files Browse the repository at this point in the history
  • Loading branch information
tanakaryo committed Jun 9, 2024
1 parent 8bbde58 commit 6734c8c
Show file tree
Hide file tree
Showing 661 changed files with 93,394 additions and 0 deletions.
13 changes: 13 additions & 0 deletions nodejs/app4/classexample/business_person.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { Person } = require("./iface/person");

module.exports = class BusinessPerson extends Person {
constructor(name, age, country, job) {
super(name, age, country);
this.job = job
}

sayHello() {
super.sayHello();
console.log(`I'm work as ${this.job}.`);
}
}
16 changes: 16 additions & 0 deletions nodejs/app4/classexample/iface/person.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Person {
constructor(name, age, country) {
this.name = name;
this.age = age;
this.country = country;
}

sayHello() {
console.log(`Hello, my name is ${this.name}.`);
console.log(`I'm ${this.age} years old.`);
console.log(`I'm live in ${this.country}.`);
}
}

module.exports = { Person };

5 changes: 5 additions & 0 deletions nodejs/app4/classexample/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const BusinessPerson = require("./business_person");


let bzp = new BusinessPerson("satoshi", 14, "Japan", "Student");
bzp.sayHello();
24 changes: 24 additions & 0 deletions nodejs/app5/connectmysql/delete_data_main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const mysql = require('mysql')

const conn = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'password',
database: 'employee_db'
});

conn.connect((err) => {
if (err) {
console.log('connection establish is failed.' + err.stack());
return;
}
console.log('connection established.');
});

conn.query('DELETE FROM users WHERE id=?',
[5], (error, results) => {
console.log(results);
}
);

console.log('deleting data is success.');
22 changes: 22 additions & 0 deletions nodejs/app5/connectmysql/insert_data_main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const mysql = require('mysql')

const conn = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'password',
database: 'employee_db'
});

conn.connect((err) => {
if (err) {
console.log('connection failed. ' + err.stack);
return;
}
console.log('connection success.');
});

conn.query('INSERT INTO users(id, department_id, email, first_name, last_name) VALUES (?,?,?,?,?)'
, [5, '1', '[email protected]', 'J.M', 'Weston'], (error, results) => {
console.log(results);
})

1 change: 1 addition & 0 deletions nodejs/app5/connectmysql/node_modules/.bin/mime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6734c8c

Please sign in to comment.