简体   繁体   中英

how to create mysql schema in nodejs

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);

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM