-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
56 lines (51 loc) · 1003 Bytes
/
Copy pathapp.js
File metadata and controls
56 lines (51 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const express = require("express");
const Sequelize = require("sequelize");
const app = express();
const PORT = 8087;
// connection with mysql
const connection = new Sequelize("node_orm", "root", "", {
host: "localhost",
dialect: "mysql",
});
const user = connection.define("tbl_users",{
id:{
type:Sequelize.INTEGER,
allowNull :false,
primaryKey:true,
autoIncrement:true
},
name:{
type:Sequelize.STRING,
allowNull:false
},
email:{
type:Sequelize.STRING,
},
rollNo:{
type:Sequelize.INTEGER,
},
status:{
type:Sequelize.ENUM("1","0"),
default:"1"
}
},{
modelName:"User"
}
)
connection.sync()
connection
.authenticate()
.then(() => {
console.info('INFO - Database connected.')
}).catch(()=>{
console.info("Error in conncting with database")
})
app.get("/", (req, res) => {
res.status(200).json({
status: true,
message: "Welcome top Home page.",
});
});
app.listen(PORT, () => {
console.log("app is runnig.");
});