-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommentSeeder.js
32 lines (27 loc) · 887 Bytes
/
commentSeeder.js
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
import * as database from "./database/index.js"
import { Comment } from "./modules/comment/model.js";
import readline from 'readline'
database.connectDB();
const readInput = readline.createInterface({
input: process.stdin,
output: process.stdout
})
readInput.question(`Enter post id to create comments for: `, postId => {
const comments = [
{ comment: 'Comment 1', post: postId },
{ comment: 'Comment 2', post: postId },
{ comment: 'Comment 3', post: postId },
{ comment: 'Comment 4', post: postId },
{ comment: 'Comment 5', post: postId },
{ comment: 'Comment 6', post: postId },
];
try {
for (const comment of comments) {
Comment.create(comment);
console.log(`Created Item ${comment.comment}`);
}
} catch (e) {
console.error(e);
}
readInput.close()
})