-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
44 lines (32 loc) · 1.1 KB
/
index.js
File metadata and controls
44 lines (32 loc) · 1.1 KB
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
37
38
39
40
41
42
43
44
const { sequelize, Member, Post, Reply } = require('./sequelize')
const faker = require('faker')
var count = 5;
var member_ids = [];
async function createMembers() {
// create some members.
for (i =0 ;i < count; i++){
//INSERT INTO cloudclub.clubmembers VALUES (''.''.'')
const member = await Member.create({ name: faker.name.findName(), bio: faker.random.words(), email: faker.internet.email() });
member_ids.push(member.id);
}
}
async function createPosts() {
//create some posts and replies.
for (i =0 ;i < count; i++){
const post = await Post.create({ body: faker.random.words(), subject: faker.random.words(), userid: member_ids[i] });
const reply = await Reply.create({ body: faker.random.words(), postid: post.id, userid: member_ids[i] });
}
}
async function createReplies() {
//find replies by a userid
for (i =0 ;i < count; i++){
const found_reply = await Reply.findAll({where: {userid: member_ids[i]}});
console.log(found_reply);
}
}
async function main(){
await createMembers();
await createPosts();
await createReplies();
};
main();