Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Commit

Permalink
Add database seeder for user tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
kkamara committed Aug 15, 2023
1 parent dba2a4e commit 62c807a
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/seeders/20230815142038-demo-user-token.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use strict';
const db = require('../models/index');
const config = require('../config/index');
const { hash: hash1 } = db.sequelize.models
.User
.encrypt(config.appKey);
const { hash: hash2 } = db.sequelize.models
.User
.encrypt(config.appKey);
const { hash: hash3 } = db.sequelize.models
.User
.encrypt(config.appKey);
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up (queryInterface, Sequelize) {
return queryInterface.bulkInsert('UserTokens', [
{
usersId: 1,
token: hash1,
createdAt: new Date(),
updatedAt: new Date(),
},
{
usersId: 2,
token: hash2,
createdAt: new Date(),
updatedAt: new Date(),
},
{
usersId: 3,
token: hash3,
createdAt: new Date(),
updatedAt: new Date(),
},
]);
},

async down (queryInterface, Sequelize) {
return queryInterface.bulkDelete('Users', null, {});
}
};

0 comments on commit 62c807a

Please sign in to comment.