-
-
Notifications
You must be signed in to change notification settings - Fork 677
/
helpers.ts
36 lines (33 loc) · 902 Bytes
/
helpers.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { RecipeModel } from "./entities/recipe";
import { User, UserModel } from "./entities/user";
export async function seedDatabase() {
const defaultUser = new UserModel({
email: "[email protected]",
nickname: "MichalLytek",
password: "s3cr3tp4ssw0rd",
} as User);
await defaultUser.save();
await RecipeModel.create([
{
title: "Recipe 1",
description: "Desc 1",
author: defaultUser._id,
ratings: [
{ value: 2, user: defaultUser._id },
{ value: 4, user: defaultUser._id },
{ value: 5, user: defaultUser._id },
{ value: 3, user: defaultUser._id },
{ value: 4, user: defaultUser._id },
],
},
{
title: "Recipe 2",
author: defaultUser._id,
ratings: [
{ value: 2, user: defaultUser },
{ value: 4, user: defaultUser },
],
},
]);
return { defaultUser };
}