mysql使用笔记

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']]
    })
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容