Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
H
Homework_89_Tsoy_Danil
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Цой Данил
Homework_89_Tsoy_Danil
Commits
250bc1a7
Commit
250bc1a7
authored
Mar 14, 2023
by
Цой Данил
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#1
added models for artists and wrote method to get them
parent
6b6f0134
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
+48
-0
Artist.ts
src/models/Artist.ts
+21
-0
atistsService.ts
src/services/atistsService.ts
+27
-0
No files found.
src/models/Artist.ts
View file @
250bc1a7
import
mongoose
from
"mongoose"
;
import
IArtist
from
"../interfaces/IArtist"
;
const
Schema
=
mongoose
.
Schema
const
ArtistSchema
=
new
Schema
<
IArtist
>
({
name
:{
type
:
String
,
require
:
true
},
photo
:{
type
:
String
,
require
:
true
},
information
:{
type
:
String
,
require
:
true
}
})
export
const
Artist
=
mongoose
.
model
<
IArtist
>
(
'Artist'
,
ArtistSchema
)
\ No newline at end of file
src/services/atistsService.ts
View file @
250bc1a7
import
{
EStatuses
}
from
"../enum/EStatuses"
;
import
IArtist
from
"../interfaces/IArtist"
;
import
IResponse
from
"../interfaces/IResponse"
;
import
{
Artist
}
from
"../models/Artist"
;
export
class
ArtistsService
{
public
getArtists
=
async
():
Promise
<
IResponse
<
IArtist
[]
|
null
>>
=>
{
try
{
const
data
=
await
Artist
.
find
()
const
response
:
IResponse
<
IArtist
[]
>
=
{
status
:
EStatuses
.
SUCCESS
,
result
:
data
,
message
:
'Artists found'
}
return
response
}
catch
(
err
:
unknown
){
const
error
=
err
as
Error
const
response
:
IResponse
<
null
>
=
{
status
:
EStatuses
.
FAILURE
,
result
:
null
,
message
:
error
.
message
}
return
response
}
}
}
\ No newline at end of file
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