how to create mysql schema in nodejs

∥☆過路亽.° 提交于 2020-05-12 11:35:50

问题


I am using nodejs, express framework and mysql for my database. I would like to know how can I replicate this mongoose code using mysql. I cannot find a way to write my sql schema in a nodejs file. Do I have to use workbench for this? Thanks!

var mongoose = require('mongoose');

var userSchema = mongoose.Schema({
    local: {
            username: String,
            password: String
         }
 });

module.exports = mongoose.model('User', userSchema);

回答1:


you can use any of:
bookshelf
knex
objection
orm
sequelize

see compare between that:

https://npmcompare.com/compare/bookshelf,knex,objection,orm,sequelize

This tutorial maybe help you to use of "sequelize": Creating a Role-Based User Authentication System with Angular, Express and MySQL



来源:https://stackoverflow.com/questions/34039489/how-to-create-mysql-schema-in-nodejs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!