Complete backend
This commit is contained in:
22
api/models/citiesModel.js
Normal file
22
api/models/citiesModel.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const db = require('../../data/dbConfig');
|
||||
|
||||
module.exports = {
|
||||
getCities,
|
||||
getCitiesByCountry
|
||||
// getCity,
|
||||
};
|
||||
|
||||
function getCities() {
|
||||
return db('cities')
|
||||
}
|
||||
|
||||
function getCitiesByCountry(country_id) {
|
||||
return db('cities')
|
||||
.where({ country_id })
|
||||
}
|
||||
|
||||
// function getCity(name) {
|
||||
// return db('cities')
|
||||
// .where({ name })
|
||||
// .first()
|
||||
// }
|
||||
16
api/models/countriesModel.js
Normal file
16
api/models/countriesModel.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const db = require('../../data/dbConfig');
|
||||
|
||||
module.exports = {
|
||||
getCountries,
|
||||
getCountryByName,
|
||||
};
|
||||
|
||||
function getCountries() {
|
||||
return db('countries')
|
||||
}
|
||||
|
||||
function getCountryByName(name) {
|
||||
return db('countries')
|
||||
.where({ name })
|
||||
.first()
|
||||
}
|
||||
9
api/models/roadsModel.js
Normal file
9
api/models/roadsModel.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const db = require('../../data/dbConfig');
|
||||
|
||||
module.exports = {
|
||||
getRoads
|
||||
};
|
||||
|
||||
function getRoads() {
|
||||
return db('roads')
|
||||
}
|
||||
Reference in New Issue
Block a user