#13 added roles and fixture

parent 54cdfc60
...@@ -24,56 +24,88 @@ db.once('open', async () => { ...@@ -24,56 +24,88 @@ db.once('open', async () => {
{ {
username: 'alen', username: 'alen',
password: '1', password: '1',
role: 'Admin',
}, },
{ {
username: 'danil', username: 'danil',
password: '2', password: '2',
role: 'User',
} }
); );
const firstArtistId = new mongoose.Types.ObjectId(); const drakeId = new mongoose.Types.ObjectId();
const secondArtisId = new mongoose.Types.ObjectId(); const eminemId = new mongoose.Types.ObjectId();
const kizaruId = new mongoose.Types.ObjectId();
const snoopId = new mongoose.Types.ObjectId();
await ArtistModel.create( await ArtistModel.create(
{ {
_id: firstArtistId, _id: drakeId,
info: 'Aubrey Drake Graham is a Canadian rapper and singer. An influential global figure in contemporary popular music, Drake has been credited for popularizing singing and R&B sensibilities in hip hop.', info: 'Aubrey Drake Graham is a Canadian rapper and singer. An influential global figure in contemporary popular music, Drake has been credited for popularizing singing and R&B sensibilities in hip hop.',
name: 'Drake', name: 'Drake',
photo: 'drake.jpg', photo: 'drake.jpg',
}, },
{ {
_id: secondArtisId, _id: eminemId,
info: 'Marshall Bruce Mathers III, known professionally as Eminem, is an American rapper, songwriter, and record producer. He is credited with popularizing hip hop in middle America and is critically acclaimed as one of the greatest rappers of all time.', info: 'Marshall Bruce Mathers III, known professionally as Eminem, is an American rapper, songwriter, and record producer. He is credited with popularizing hip hop in middle America and is critically acclaimed as one of the greatest rappers of all time.',
name: 'Eminem', name: 'Eminem',
photo: 'eminem.png', photo: 'eminem.png',
},
{
_id: kizaruId,
info: 'Рэп-исполнитель новой волны, проживающий в Барселоне',
name: 'Kizaru',
photo: 'kizaru.jpg',
},
{
_id: snoopId,
info: 'Calvin Cordozar Broadus Jr. (born October 20, 1971), known professionally as Snoop Dogg is an American rapper and actor.',
name: 'Snoop Dogg',
photo: 'snoop.jpg',
} }
); );
const firstAlbumId = new mongoose.Types.ObjectId(); const firstAlbumId = new mongoose.Types.ObjectId();
const secondAlbumId = new mongoose.Types.ObjectId(); const secondAlbumId = new mongoose.Types.ObjectId();
const thirdAlbumId = new mongoose.Types.ObjectId(); const thirdAlbumId = new mongoose.Types.ObjectId();
const fourthAlbumId = new mongoose.Types.ObjectId();
const fifthAlbumId = new mongoose.Types.ObjectId();
await AlbumModel.create( await AlbumModel.create(
{ {
_id: firstAlbumId, _id: firstAlbumId,
artist: firstArtistId, artist: drakeId,
image: 'album1.jpg', image: 'album1.jpg',
year: 2001, year: 2001,
name: 'Room for Improvement', name: 'Room for Improvement',
}, },
{ {
_id: secondAlbumId, _id: secondAlbumId,
artist: firstArtistId, artist: drakeId,
image: 'album2.jpg', image: 'album2.jpg',
year: 2005, year: 2005,
name: 'Comeback Season', name: 'Comeback Season',
}, },
{ {
_id: thirdAlbumId, _id: thirdAlbumId,
artist: secondArtisId, artist: eminemId,
image: 'album3.jpg', image: 'album3.jpg',
year: 2011, year: 2011,
name: 'One fortune', name: 'One fortune',
},
{
_id: fourthAlbumId,
artist: kizaruId,
image: 'kizaruAlbum.jpg',
year: 2005,
name: 'Bandana',
},
{
_id: fifthAlbumId,
artist: snoopId,
image: 'snoopAlbum.jpg',
year: 2005,
name: 'High',
} }
); );
...@@ -81,12 +113,127 @@ db.once('open', async () => { ...@@ -81,12 +113,127 @@ db.once('open', async () => {
{ {
album: firstAlbumId, album: firstAlbumId,
duration: '2:56', duration: '2:56',
name: 'Predator', name: 'sfdg12',
},
{
album: firstAlbumId,
duration: '2:56',
name: 'sdfsadfsad',
},
{
album: firstAlbumId,
duration: '2:36',
name: '12312',
},
{
album: firstAlbumId,
duration: '2:56',
name: 'sadf',
},
{
album: firstAlbumId,
duration: '2:56',
name: 'gfjgfh',
},
{
album: secondAlbumId,
duration: '3:10',
name: 'hgjfgh',
},
{
album: secondAlbumId,
duration: '3:10',
name: 'sadfasd',
}, },
{ {
album: secondAlbumId, album: secondAlbumId,
duration: '3:10', duration: '3:10',
name: 'Mommy', name: '21312312',
},
{
album: secondAlbumId,
duration: '3:10',
name: 'sadfasfasd',
},
{
album: secondAlbumId,
duration: '3:10',
name: 'asdvdsa',
},
{
album: thirdAlbumId,
duration: '3:10',
name: 'hgjfgh',
},
{
album: thirdAlbumId,
duration: '3:10',
name: 'sadfasd',
},
{
album: thirdAlbumId,
duration: '3:10',
name: '21312312',
},
{
album: thirdAlbumId,
duration: '3:10',
name: 'sadfasfasd',
},
{
album: thirdAlbumId,
duration: '3:10',
name: 'asdvdsa',
},
{
album: fourthAlbumId,
duration: '3:10',
name: 'hgjfgh',
},
{
album: fourthAlbumId,
duration: '3:10',
name: 'sadfasd',
},
{
album: fourthAlbumId,
duration: '3:10',
name: '21312312',
},
{
album: fourthAlbumId,
duration: '3:10',
name: 'sadfasfasd',
},
{
album: fourthAlbumId,
duration: '3:10',
name: 'asdvdsa',
},
{
album: fifthAlbumId,
duration: '3:10',
name: 'hgjfgh',
},
{
album: fifthAlbumId,
duration: '3:10',
name: 'sadfasd',
},
{
album: fifthAlbumId,
duration: '3:10',
name: '21312312',
},
{
album: fifthAlbumId,
duration: '3:10',
name: 'sadfasfasd',
},
{
album: fifthAlbumId,
duration: '3:10',
name: 'asdvdsa',
} }
); );
......
...@@ -5,4 +5,5 @@ export default interface IUser extends mongoose.Document { ...@@ -5,4 +5,5 @@ export default interface IUser extends mongoose.Document {
username: string; username: string;
password: string; password: string;
token: string; token: string;
role: string;
} }
...@@ -18,6 +18,12 @@ const UserSchema: mongoose.Schema<IUser> = new mongoose.Schema<IUser>( ...@@ -18,6 +18,12 @@ const UserSchema: mongoose.Schema<IUser> = new mongoose.Schema<IUser>(
token: { token: {
type: String, type: String,
}, },
role: {
type: String,
required: true,
default: 'User',
enum: ['User', 'Admin'],
},
}, },
{versionKey: false} {versionKey: false}
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment