Sequelize Create Database

I may have a reasonable solution. I am sure it could be written more cleanly though. For this example I’m using Postgres, the answer would be slightly different for MySQL. I’m heavily borrowing from this answer: node-postgres create database In database.js I have the following init function var Sequelize = require(‘sequelize’), pg = require(‘pg’); module.exports.init … Read more

How to get a distinct count with sequelize?

UPDATE: New version There are now separate distinct and col options. The docs for distinct state: Apply COUNT(DISTINCT(col)) on primary key or on options.col. You want something along the lines of: MyModel.count({ include: …, where: …, distinct: true, col: ‘Product.id’ }) .then(function(count) { // count is an integer }); Original Post (As mentioned in the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)