Node+TS+Koa+vue 商城全栈(三) sequelize 创建种子文件
2023-09-11 14:15:29 时间
1.用户表种子文件(示例):
seeders/20200204173530-user.js
const md5 = require('md5'); const moment = require('moment'); module.exports = { up: (queryInterface, Sequelize) => { /* Add altering commands here. Return a promise to correctly handle asynchronicity. Example: return queryInterface.bulkInert('Person', [{ name: 'John Doe', isBetaMember: false }], {}); */ return queryInterface.bulkInsert('user', [ { id: 1, username: 'mt', password: md5('123456'), disabled: false, mobile: '13000000000', email: 'mt@meishi.com', created_ip_at: '127.0.0.1', updated_ip_at: '127.0.0.1', created_at: moment().format('YYYY-MM-DD HH:mm:ss'), updated_at: moment().format('YYYY-MM-DD HH:mm:ss') }, { id: 2, username: 'zmouse', password: md5('123456'), disabled: false, mobile: '13000000000', email: 'zmouse@meishi.com', created_ip_at: '127.0.0.1', updated_ip_at: '127.0.0.1', created_at: moment().format('YYYY-MM-DD HH:mm:ss'), updated_at: moment().format('YYYY-MM-DD HH:mm:ss') }, { id: 3, username: 'reci', password: md5('123456'), disabled: false, mobile: '13000000000', email: 'reci@meishi.com', created_ip_at: '127.0.0.1', updated_ip_at: '127.0.0.1', created_at: moment().format('YYYY-MM-DD HH:mm:ss'), updated_at: moment().format('YYYY-MM-DD HH:mm:ss') }, { id: 4, username: 'kimoo', password: md5('123456'), disabled: false, mobile: '13000000000', email: 'kimoo@meishi.com', created_ip_at: '127.0.0.1', updated_ip_at: '127.0.0.1', created_at: moment().format('YYYY-MM-DD HH:mm:ss'), updated_at: moment().format('YYYY-MM-DD HH:mm:ss') } ]); }, down: (queryInterface, Sequelize) => { /* Add reverting commands here. Return a promise to correctly handle asynchronicity. Example: return queryInterface.bulkDelete('Person', null, {}); */ return queryInterface.bulkDelete('user', null, {}); } };
根据种子文件添加数据
.\node_modules\.bin\sequelize db:seed:all
根据种子文件清空数据
.\node_modules\.bin\sequelize db:seed:undo:all
2.项目目录:
相关文章
- axios和vue-axios的关系
- vscode编辑器自动生成.vue文件
- vue-cli脚手架
- [VueJS + Typescript] Decouple Dependencies Using IoC Containers in Vue with TypeScript and InversifyJS
- [Vue + TS] Write a Vue Component as a Class in TypeScript
- php/nginx/axios: 文件上传: 配置最长执行时间等相关项 (php8.1.1 / nginx 1.18.0 / vue@3.2.26 )
- EasyDSS高性能RTMP、HLS(m3u8)、HTTP-FLV、RTSP流媒体服务器前端源码重构(二)-webpack + vue + AdminLTE 多页面提取共用文件, 优化编译时间
- vue项目中axios封装总结
- vue.js 3.2.22:多选上传图片带缩略图可删除
- 从vue-cli2.x升级到@vue/cli 4.x(node v14.15.0 / vue.js 3.0)
- Vue中vue-i18n结合vant-ui实现国际化
- 218:vue+openlayers 加载geotiff文件,显示图形
- 216:vue+openlayers 加载GPX数据,导出geojson文件
- 116:vue+openlayers的loadstart事件和loadend事件( 示例代码 )
- 037:vue+openlayers上传包含shp的zip文件并解析(代码示例)
- Linux安装最新版Vue或者指定版本
- 如何在vue组件中引入外部的css和js文件
- 2023前端面试重点知识点总结【详细】css+js+vue+react+小程序+性能优化等等