如何在nodejs中创建mysql模式 [英] how to create mysql schema in nodejs

查看:167
本文介绍了如何在nodejs中创建mysql模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的数据库使用nodejs,express framework和mysql. 我想知道如何使用mysql复制此猫鼬代码.我找不到在nodejs文件中编写SQL模式的方法.我必须为此使用工作台吗?谢谢!

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

推荐答案

您可以使用以下任何一种方式:
书架
knex
异议
Orm
续集

you can use any of:
bookshelf
knex
objection
orm
sequelize

查看两者之间的比较:

https://npmcompare.com/compare/bookshelf、knex,异议, orm,sequelize

本教程可能会帮助您使用"sequelize": 使用Angular创建基于角色的用户身份验证系统,Express和MySQL

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

这篇关于如何在nodejs中创建mysql模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆