You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CREATEDATABASEboard;
CREATEUSER 'class'@'localhost' IDENTIFIED BY '101';
ALTERUSER'class'@'localhost' IDENTIFIED WITH mysql_native_password BY '101';
GRANT ALL PRIVILEGES ON board.* TO 'class'@'localhost';
FLUSH PRIVILEGES;
// app.js// This code block will generate dummy data and insert them into the DB// set this true if you want to reset DB.awaitdb.sequelize.sync({force: true});// When this block is active, dummy data will be created every time you restart server// To stop creating dummies, make this code below as commentsawaitdb.sequelize.sync({force: false});constuserIds=awaitdb.User.findAll().map(user=>user.id);constnewUserIds=[
...newSet(['admin', ...times(10,()=>faker.name.firstName())].filter(id=>!userIds.includes(id)))];awaitdb.User.bulkCreate(newUserIds.map(id=>({
id,name: `${id}${faker.name.lastName()}`})));console.log(newUserIds,newUserIds.length);letposts=awaitdb.Post.bulkCreate(times(30,()=>({title: faker.lorem.sentence(),content: faker.lorem.paragraph(),userId: newUserIds[random(0,newUserIds.length-1)]})));postIds=posts.map(post=>post.id);awaitdb.Comment.bulkCreate(times(300,()=>({content: faker.lorem.sentence(),userId: newUserIds[random(0,newUserIds.length-1)],postId: postIds[random(0,10)]})));
About
RESTful API and GraphQL Server with MySQL. Sequelize