knexjs操作数据库

knexjs操作数据库

Knex.js is a "batteries included" SQL query builder for Postgres, MSSQL, MySQL, MariaDB, SQLite3, Oracle, and Amazon Redshift designed to be flexible, portable, and fun to use. It features both traditional node style callbacks as well as a promise interface for cleaner async flow control, a stream interface, full featured query and schema builders, transaction support (with savepoints), connection pooling and standardized responses between different query clients and dialects.
没什么要说的,就是操作数据库

mysql('mpArticle').orderBy('id','desc').limit(1)
//查找最近一条记录
mysql('mpArticle').insert(postdata)
//插入数据库
mysql('user').where('wx_openid', user.wx_openid).count('wx_openid as i')
//判断数据是否存在
mysql('usefulTel').select('company_pic')
//查询筛选
mysql('user').update('user_phone', movecar.user_phone).where('wx_openid', openid)
//更新数据库
来都来了,留个言吧🙂