-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
…a kreiranje tabela i njihovih veza )
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Launch Program", | ||
"program": "${workspaceFolder}\\index.js" | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const Sequelize = require("sequelize"); | ||
const sequelize = new Sequelize( | ||
"TYQcLL35gV", // database | ||
"TYQcLL35gV", // username | ||
"BLysSj9ZrP", // password | ||
{host:"37.59.55.185",dialect:"mysql"}); | ||
|
||
const db={}; | ||
|
||
db.Sequelize = Sequelize; | ||
db.sequelize = sequelize; | ||
|
||
//import modela | ||
db.zadaca = sequelize.import(__dirname + '/zadaca.js'); | ||
db.zadatak = sequelize.import(__dirname + '/zadatak.js'); | ||
db.mimeTip = sequelize.import(__dirname + '/mimeTip.js'); | ||
|
||
//relacije | ||
db.zadaca.hasMany(db.zadatak, {as: 'zadaci' , foreignKey: 'idZadaca' }); | ||
db.zadatak.hasMany(db.mimeTip, {as: 'mimeTipovi' , foreignKey: 'idZadatak' }); | ||
|
||
module.exports=db; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const express = require('express'); | ||
const morgan = require('morgan'); | ||
const bodyParser = require('body-parser'); | ||
const db = require('./dbComponents/db.js'); | ||
const app = express(); | ||
|
||
app.use(bodyParser.json()); | ||
app.use(bodyParser.urlencoded({ extended: true })); | ||
app.use(morgan('dev')) | ||
|
||
db.sequelize.sync({force:false}).then(() => { | ||
console.log("Usao u bazu!"); | ||
}).catch((e) => { | ||
console.log("greska"); | ||
console.log(e); | ||
}); | ||
|
||
|
||
app.post('/addZadaca', function(req, res) { | ||
|
||
var bodyReq = req.body; | ||
|
||
|
||
|
||
|
||
res.end("test1"); | ||
}); | ||
|
||
app.listen(6001); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.