Added a new model - does not work yet
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
const RealEstateRequest = require('../models/RealEstateRequest');
|
||||
|
||||
const vrsteNekretnina = [
|
||||
{ ime: "Kuća", id: "kuca" },
|
||||
{ ime: "Stan", id: "stan" },
|
||||
@@ -12,6 +14,18 @@ const getVrstaNekretnine = (req,res) => {
|
||||
});
|
||||
}
|
||||
|
||||
const postVrstaNekretnine = (req, res) => {
|
||||
RealEstateRequest.create({
|
||||
real_estate_type: req.body.vrsta
|
||||
}).then( (result) => {
|
||||
res.send("Result is " + JSON.stringify(result));
|
||||
}).catch( (e) => {
|
||||
res.send(e);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getVrstaNekretnine
|
||||
getVrstaNekretnine,
|
||||
postVrstaNekretnine
|
||||
};
|
||||
|
||||
25
app/models/RealEstateRequest.js
Normal file
25
app/models/RealEstateRequest.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const Sequelize = require("sequelize");
|
||||
const sequelize = require("../db/db");
|
||||
const RealEstateRequest = sequelize.define("real_estate_request", {
|
||||
id: {
|
||||
type: Sequelize.INTEGER,
|
||||
autoIncrement: true,
|
||||
primaryKey: true
|
||||
},
|
||||
unique_id: {
|
||||
type: Sequelize.UUID,
|
||||
defaultValue: Sequelize.UUIDV4,
|
||||
allowNull: false,
|
||||
},
|
||||
real_estate_type: {
|
||||
type: Sequelize.ENUM,
|
||||
values: ['kuca', 'stan', 'vikendica']
|
||||
},
|
||||
email: {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: true
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = RealEstateRequest;
|
||||
|
||||
4
index.js
4
index.js
@@ -1,5 +1,6 @@
|
||||
const dobrodosli = require('./app/controllers/dobrodosli').getDobrodosli;
|
||||
const getVrstaNekretnine = require('./app/controllers/vrsta_nekretnine').getVrstaNekretnine;
|
||||
const postVrstaNekretnine = require('./app/controllers/vrsta_nekretnine').postVrstaNekretnine;
|
||||
|
||||
let express = require("express");
|
||||
const path = require("path");
|
||||
@@ -107,7 +108,8 @@ app.post("/api/payforalert", function(request, response) {
|
||||
});
|
||||
|
||||
app.get('/', dobrodosli);
|
||||
app.get('/vrstanekretnine', getVrstaNekretnine);
|
||||
app.get('/vrstanekretnine', getVrstaNekretnine);
|
||||
app.post('/vrstanekretnine', postVrstaNekretnine);
|
||||
app.use('/assets', express.static('./app/public'))
|
||||
|
||||
app.listen(port, () => console.log(`Example app listening on port ${port}!`));
|
||||
|
||||
739
package-lock.json
generated
739
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -29,6 +29,7 @@
|
||||
"mysql2": "^1.6.4",
|
||||
"node-fetch": "^2.3.0",
|
||||
"react-step-wizard": "^5.1.0",
|
||||
"sequelize": "^4.42.0"
|
||||
"sequelize": "^4.42.0",
|
||||
"sequelize-cli": "^5.4.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user