Commit 3b428a77 authored by Цой Данил's avatar Цой Данил 💬

Added fixtures file + filled it with data

parent ffb02e6b
* *
!.gitignore !.gitignore
!ledros.jpg
!aurelion_sol.jpg
!dark_start_morde.jpg
!quinn.jpg
!darius.jpg
!yi.jpg
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
import dotenv from 'dotenv'
import mongoose from 'mongoose'
import { User } from './models/User'
import { Photo } from './models/Photo'
dotenv.config()
mongoose.connect(process.env.MONGO_CLIENT_URL || '')
const db = mongoose.connection
export default db.once('open', async () => {
try{
await db.dropCollection('users')
await db.dropCollection('photos')
} catch(err: unknown){
console.log(`Skipped db drop because of: ${err}`);
}
const [userOne, userTwo] = await User.create(
{
username: 'user1',
password: 'pass'
},
{
username: 'user2',
password: 'pass',
}
)
await Photo.create(
{
user: userOne._id,
title: 'Darius',
photo: 'darius.jpg'
},
{
user: userOne._id,
title: 'Aurelion Sol',
photo: 'aurelion_sol.jpg'
},
{
user: userTwo._id,
title: 'Master Yi',
photo: 'yi.jpg'
},
{
user: userOne._id,
title: 'Commander Ledros',
photo: 'ledros.jpg'
},
{
user: userOne._id,
title: 'Commander Ledros',
photo: 'ledros.jpg'
},
{
user: userTwo._id,
title: 'Quinn and Valor',
photo: 'quinn.jpg'
},
{
user: userTwo._id,
title: 'Dark start Mordekaiser',
photo: 'dark_start_morde.jpg'
}
)
db.close()
})
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