Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Easy Class
backend
Commits
32446263
Commit
32446263
authored
6 years ago
by
Gustavo Jacob de Oliveira
Browse files
Options
Download
Email Patches
Plain Diff
Subindo rota get materias
parent
ee092799
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
controllers/materia/materiaController.js
+1
-1
controllers/materia/materiaController.js
index.js
+2
-2
index.js
models/Especialidade.js
+9
-0
models/Especialidade.js
models/Materia.js
+4
-3
models/Materia.js
with
16 additions
and
6 deletions
+16
-6
controllers/materia/materiaController.js
View file @
32446263
import
httpStatus
from
'
http-status
'
;
import
Materia
from
'
../../models/Materia
'
;
export
async
function
getMaterias
(
req
,
res
)
{
export
default
async
function
getMaterias
(
req
,
res
)
{
try
{
const
materias
=
await
Materia
.
find
();
return
res
.
send
(
materias
);
...
...
This diff is collapsed.
Click to expand it.
index.js
View file @
32446263
...
...
@@ -7,7 +7,7 @@ import * as userController from './controllers/user/userController';
import
*
as
alunoController
from
'
./controllers/user/alunoController
'
;
import
*
as
professorController
from
'
./controllers/user/professorController
'
;
import
*
as
classController
from
'
./controllers/class/classController
'
;
import
*
as
materiaController
from
'
./controllers/materia/materiaController
'
;
import
getMaterias
from
'
./controllers/materia/materiaController
'
;
// create and configure Express server
const
app
=
express
();
...
...
@@ -59,7 +59,7 @@ router.put('/class/:id', classController.updateClass);
router
.
delete
(
'
/class/:id
'
,
classController
.
removeClass
);
// materias
router
.
get
(
'
/materias
'
,
materiaController
.
getMaterias
);
router
.
get
(
'
/materias
'
,
getMaterias
);
app
.
use
(
'
/api
'
,
router
);
export
default
app
;
This diff is collapsed.
Click to expand it.
models/Especialidade.js
0 → 100644
View file @
32446263
import
mongoose
from
'
mongoose
'
;
export
const
especialidadeSchema
=
new
mongoose
.
Schema
({
nome
:
{
type
:
String
,
required
:
true
},
});
const
Especialidade
=
mongoose
.
model
(
'
Especialidade
'
,
especialidadeSchema
);
export
default
Especialidade
;
This diff is collapsed.
Click to expand it.
models/Materia.js
View file @
32446263
import
mongoose
from
'
mongoose
'
;
import
{
especialidadeSchema
}
from
'
./Especialidade
'
;
export
const
materiaSchema
=
new
mongoose
.
Schema
({
grau
:
{
type
:
Number
,
required
:
true
},
nome
:
{
type
:
String
,
required
:
true
},
especializacoes
:
{
type
:
[
String
],
required
:
false
},
nome
:
{
type
:
String
,
required
:
true
},
especialidades
:
{
type
:
[
especialidadeSchema
],
required
:
false
},
});
const
Materia
=
mongoose
.
model
(
'
Materia
'
,
materiaSchema
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment