Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
H
hw87AlenBolatov
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
Болатов Ален
hw87AlenBolatov
Commits
fac8d15e
Commit
fac8d15e
authored
Mar 25, 2023
by
Болатов Ален
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added auto increment to tracks
parent
7968bb03
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4112 additions
and
1763 deletions
+4112
-1763
package-lock.json
backend/package-lock.json
+4099
-1762
package.json
backend/package.json
+2
-0
ITrack.ts
backend/src/interfaces/ITrack.ts
+1
-0
track.ts
backend/src/models/track.ts
+10
-1
No files found.
backend/package-lock.json
View file @
fac8d15e
This diff is collapsed.
Click to expand it.
backend/package.json
View file @
fac8d15e
...
...
@@ -23,6 +23,7 @@
"joi"
:
"^17.9.1"
,
"jsonwebtoken"
:
"^9.0.0"
,
"mongoose"
:
"^7.0.1"
,
"mongoose-sequence"
:
"^5.3.1"
,
"multer"
:
"^1.4.5-lts.1"
,
"ts-node-dev"
:
"^2.0.0"
},
...
...
@@ -31,6 +32,7 @@
"@types/express"
:
"^4.17.17"
,
"@types/jsonwebtoken"
:
"^9.0.1"
,
"@types/mongoose"
:
"^5.11.97"
,
"@types/mongoose-sequence"
:
"^3.0.7"
,
"@types/multer"
:
"^1.4.7"
}
}
backend/src/interfaces/ITrack.ts
View file @
fac8d15e
...
...
@@ -4,4 +4,5 @@ export default interface ITrack {
name
:
string
;
album
:
ObjectId
;
duration
:
string
;
seq
?:
Number
;
}
backend/src/models/track.ts
View file @
fac8d15e
import
{
model
,
Schema
}
from
'mongoose'
;
import
mongoose
,
{
model
,
Schema
}
from
'mongoose'
;
import
ITrack
from
'../interfaces/ITrack'
;
const
TrackSchema
=
new
Schema
<
ITrack
>
(
...
...
@@ -19,9 +19,18 @@ const TrackSchema = new Schema<ITrack>(
required
:
[
true
,
'Duration is required'
],
trim
:
true
,
},
seq
:
{
type
:
Number
,
},
},
{
versionKey
:
false
}
);
TrackSchema
.
pre
(
'save'
,
{
document
:
true
,
query
:
false
},
async
function
()
{
const
count
=
await
TrackModel
.
count
();
this
.
seq
=
count
+
1
;
});
const
TrackModel
=
model
<
ITrack
>
(
'track'
,
TrackSchema
);
export
default
TrackModel
;
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