美文网首页
mysql使用笔记

mysql使用笔记

作者: Jalon | 来源:发表于2016-12-06 15:31 被阅读0次

mysql命令行交互时的命令记得加分号

Paste_Image.png

orm使用sequelize。

// 表的每条记录对应的对象schema
var Project = sequelize.define('table_project', {
    id: {type : Sequelize.INTEGER, autoIncrement : true, primaryKey : true, unique : true},
    project_id: { type: Sequelize.STRING, comment: '项目的id'},
    online_url: { type: Sequelize.STRING, comment: '项目的线上接口地址'},
    offline_url: { type: Sequelize.STRING, comment: '项目的测试接口地址'},
    params: { type: Sequelize.TEXT('long') , comment: '接口json描述'},
    extra: { type: Sequelize.TEXT('long') , comment: '预留的额外配置', allowNull: true}
});

Project.sync().then(function(){
    console.log(arguments);
    doDbAction();
}, function (err) {
    console.log('err', arguments)
});

多条件或关系模糊查找

Project.findAll({
        where: {
            $or: [{
                project_name: {
                    $like: '%' + text + '%'
                }
            }, {
                user_id: {
                    $like: '%' + text + '%'
                }
            }]
        },
        order: [['updatedAt', 'DESC']]
    })

相关文章

网友评论

      本文标题:mysql使用笔记

      本文链接:https://www.haomeiwen.com/subject/qgkrmttx.html