what are models in backend code example
Example: what is model in backend
//Frontend
const getUsers = async () => {
const response = await fetch('https://yourapi.com/api/users');
const data = await response.json();
return data; //Our users
}
//Backend
//./routes/
//If we recieve a call to /api/users we call to usersController
app.get('/api/users', usersController)
// ./controllers
const usersControllers = () => {
const users = modelUser.get();//Ey model give me users from database
//Do logic with our users and return it
}
// ./models
const modelUser = {
get: () => databaseCall('SELECT * FROM users'); //Ey database give me users
}