Skip to content

Instantly share code, notes, and snippets.

Avatar

Derdus derduskenga

View GitHub Profile
View 20200729133702-demo-post.js
'use strict';
const fake = require('faker');
module.exports = {
up: async (queryInterface, Sequelize) => {
let users = await queryInterface.sequelize.query(
`SELECT id from Users;`
);
let posts = [];
for(let i=0; i<=100; i++){
View 20200729131649-demo-users.js
'use strict';
const fake = require('faker');
module.exports = {
up: async (queryInterface, Sequelize) => {
let users = [];
for(let i=0; i<=100; i++){
users.push({
name: fake.name.firstName(),
email:fake.internet.email(),
createdAt:new Date(),
View posttag.js
'use strict';
const {
Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
class PostTag extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
View tag.js
'use strict';
const {
Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
class Tag extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
View post.js
'use strict';
const {
Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
class Post extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
@derduskenga
derduskenga / 20200729005825-create-user.js
Last active Jul 29, 2020
decoded app - setting up node app
View 20200729005825-create-user.js
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('Users', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},