NODE.JS ORM之sequelize 框架
2017-02-18 15:03
375 查看
1、安装:
var fsl = sequelize.import(__dirname + "/models/frontlog")
sequelize.query('SELECT top 3 int_flowid,vch_logtype,vch_operID,dt_operdate from front_sys_log where vch_operID = ? and int_flowid > ? ', {
replacements: ['1001',1],
type: sequelize.QueryTypes.SELECT
}).then((data) => {
console.log(data);
});
fsl.create({
id:3,
vch_logtype: '系统管理日志',
vch_operID: '1002',
dt_operdate: '2017-05-02 17:42:42.950',
vch_computer: 'ZM-HEHM',
vch_function: '登录',
vch_functype: '系统管理',
vch_description: '登录后台管理系统!'
}, {
returning: false
}).then(function (task) {
console.log(task);
})
npm install sequelize //ORM 主框架
npm install -g sequelize-auto // 已有数据库表生成modle工具 2、已有的数据库生成modlenpm install -g tedious //安装MSSQL数据库驱动。sequelize-auto -o "./models" -d zmcs -h localhost -u sa_ -p 1433 -x 422426362227001 -e mssql -c zmcy.json
zmcy.json 文件内容 { "dialect": "mssql", "dialectOptions": { "tdsVersion": "7_1" //默认是7_4,对应的是sql2012以上版本, 7_1对应的是sql2000 ,需要定义驱动程序版本。 } }
Options: -h, --host IP/Hostname for the database. [required] -d, --database Database name. [required] -u, --user Username for database. -x, --pass Password for database. -p, --port Port number for database. -c, --config JSON file for Sequelize's constructor "options" flag object as defined here: https://sequelize.readthedocs.org/en/latest/api/sequelize/ -o, --output What directory to place the models. -e, --dialect The dialect/engine that you're using: postgres, mysql, sqlite -a, --additional Path to a json file containing model definitions (for all tables) which are to be defined within a model's configuration parameter. For more info: https://sequelize.readthedocs.org/en/latest/docs/models-definition/#configuration -t, --tables Comma-separated names of tables to import -C, --camel Use camel case to name models and fields -n, --no-write Prevent writing the models to disk.3、使用生成的modle
var fsl = sequelize.import(__dirname + "/models/frontlog")
sequelize.query('SELECT top 3 int_flowid,vch_logtype,vch_operID,dt_operdate from front_sys_log where vch_operID = ? and int_flowid > ? ', {
replacements: ['1001',1],
type: sequelize.QueryTypes.SELECT
}).then((data) => {
console.log(data);
});
fsl.create({
id:3,
vch_logtype: '系统管理日志',
vch_operID: '1002',
dt_operdate: '2017-05-02 17:42:42.950',
vch_computer: 'ZM-HEHM',
vch_function: '登录',
vch_functype: '系统管理',
vch_description: '登录后台管理系统!'
}, {
returning: false
}).then(function (task) {
console.log(task);
})
相关文章推荐
- Node.js ORM 框架 sequelize 实践
- Node.js ORM 框架 sequelize 实践
- NODE.JS ORM之sequelize 框架
- 在node.js中,使用基于ORM架构的Sequelize,操作mysql数据库之增删改查
- ORM DB for nodejs--sequelize
- NODEJS ORM sequelizejs 常见用法
- 关于node.js的web框架的应用及并发性能测试 推荐
- Nodejs+express+angularjs+mongodb搭建前端项目框架NJBlog
- 用Node.js 写web框架(四)
- 用Node.js 写web框架(五)
- Node.js: What is the best "full stack web framework" (with scaffolding, MVC, ORM, etc.) based on Node.js / server-side JavaScript? - Quora
- 网易开源Node.js服务端框架 pomelo 的完整安装步骤
- Nodejs+express+angularjs+mongodb搭建前端项目框架NJBlog
- HowToNodejs - fly-js-wbean - 在线游戏平台网络传输框架 - Google Project Hosting
- node测试框架:mocha+should.js
- 基于Node.js的Web框架集合
- node.js express框架文件上传路径
- 用Node.js 写web框架(三)
- 用node.js建博客(一) - node.js安装及Express框架简介
- 用Node.js 写web框架(番外)