We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
官方文档 中文文档 API
基于 promise 的 Node.js ORM
const sequelize = new Sequelize('postgres://user:[email protected]:5432/dbname');
const User = sequelize.define('user', { firstName: { type: Sequelize.STRING }, lastName: { type: Sequelize.STRING } });
user = await User.findOne() //支持async/await console.log(user.get('firstName'));
举例:where对象,Sequence.Op常量,Sequence.fn使用数据库方法,etc
async function getTimeoutCountByDay(urls, ips, includeIp, steps, duration, startTime, endTime, offset, limit) { let where = {}; if (urls && urls.length > 0) { where.url = { [Sequelize.Op.in]: urls }; } if (includeIp && ips && ips.length > 0) { where.ip = { [Sequelize.Op.in]: ips } } if (!includeIp && ips && ips.length > 0) { where.ip = { [Sequelize.Op.notIn]: ips } } if (steps && steps.length > 0) { where.step = { [Sequelize.Op.in]: steps }; } if (duration || duration === 0) { where.duration = { [Sequelize.Op.gte]: duration }; } if (startTime && endTime) { where.serverTime = { [Sequelize.Op.gte]: startTime, [Sequelize.Op.lt]: endTime }; } let res = await monitorEp5DaDao.findAll({ attributes: [ [sequelize.fn('DATE_FORMAT', sequelize.col('serverTime'), '%Y-%m-%d'), 'serverDate'], [sequelize.fn('COUNT', 'id'), 'count'] ], where: where, group: ['serverDate'], offset: offset, limit: limit }); return res; };
public static bulkCreate(records: Array, options: Object)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Sequelize.js
介绍
基于 promise 的 Node.js ORM
基本用法
建立连接
const sequelize = new Sequelize('postgres://user:[email protected]:5432/dbname');
Dao/Model/模型
简单查询
举例:where对象,Sequence.Op常量,Sequence.fn使用数据库方法,etc
更新
批量更新
public static bulkCreate(records: Array, options: Object)
The text was updated successfully, but these errors were encountered: