mysql使用笔记

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

mysql使用笔记_第1张图片
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使用笔记)