不要怂,就是干,撸起袖子干!

Commit 7a7f2d60 by Jochem Maas

rename Model "findAndCount" method to "findAndCountAll"

1 parent e1dbc3a4
...@@ -249,7 +249,7 @@ module.exports = (function() { ...@@ -249,7 +249,7 @@ module.exports = (function() {
return this.QueryInterface.rawSelect(this.tableName, options, 'count') return this.QueryInterface.rawSelect(this.tableName, options, 'count')
} }
DAOFactory.prototype.findAndCount = function(options) { DAOFactory.prototype.findAndCountAll = function(options) {
var self = this var self = this
, copts = Utils._.extend({}, options || {}) , copts = Utils._.extend({}, options || {})
......
...@@ -227,7 +227,7 @@ describe('DAOFactory', function() { ...@@ -227,7 +227,7 @@ describe('DAOFactory', function() {
}) })
}) })
describe('findAndCount', function() { describe('findAndCountAll', function() {
var users = [], fullcount = 3 var users = [], fullcount = 3
beforeEach(function() { beforeEach(function() {
...@@ -238,7 +238,7 @@ describe('DAOFactory', function() { ...@@ -238,7 +238,7 @@ describe('DAOFactory', function() {
it("handles where clause [only]", function() { it("handles where clause [only]", function() {
Helpers.async(function(done) { Helpers.async(function(done) {
User.findAndCount({where: "id != " + users[0].id}).success(function(info) { User.findAndCountAll({where: "id != " + users[0].id}).success(function(info) {
expect(info.count).toEqual(fullcount - 1) expect(info.count).toEqual(fullcount - 1)
expect(Array.isArray(info.rows)).toBeTruthy() expect(Array.isArray(info.rows)).toBeTruthy()
expect(info.rows.length).toEqual(fullcount - 1) expect(info.rows.length).toEqual(fullcount - 1)
...@@ -249,7 +249,7 @@ describe('DAOFactory', function() { ...@@ -249,7 +249,7 @@ describe('DAOFactory', function() {
it("handles where clause with ordering [only]", function() { it("handles where clause with ordering [only]", function() {
Helpers.async(function(done) { Helpers.async(function(done) {
User.findAndCount({where: "id != " + users[0].id, order: 'id ASC'}).success(function(info) { User.findAndCountAll({where: "id != " + users[0].id, order: 'id ASC'}).success(function(info) {
expect(info.count).toEqual(fullcount - 1) expect(info.count).toEqual(fullcount - 1)
expect(Array.isArray(info.rows)).toBeTruthy() expect(Array.isArray(info.rows)).toBeTruthy()
expect(info.rows.length).toEqual(fullcount - 1) expect(info.rows.length).toEqual(fullcount - 1)
...@@ -262,7 +262,7 @@ describe('DAOFactory', function() { ...@@ -262,7 +262,7 @@ describe('DAOFactory', function() {
// at time of writing (v1.6.0) Sequelize does not seem to support 'offset' on it's own consistently (goes wrong for PostGRES and SQLite) // at time of writing (v1.6.0) Sequelize does not seem to support 'offset' on it's own consistently (goes wrong for PostGRES and SQLite)
it("handles offset", function() { it("handles offset", function() {
Helpers.async(function(done) { Helpers.async(function(done) {
User.findAndCount({offset: 1}).success(function(info) { User.findAndCountAll({offset: 1}).success(function(info) {
expect(info.count).toEqual(fullcount) expect(info.count).toEqual(fullcount)
expect(Array.isArray(info.rows)).toBeTruthy() expect(Array.isArray(info.rows)).toBeTruthy()
expect(info.rows.length).toEqual(fullcount - 1) expect(info.rows.length).toEqual(fullcount - 1)
...@@ -273,7 +273,7 @@ describe('DAOFactory', function() { ...@@ -273,7 +273,7 @@ describe('DAOFactory', function() {
*/ */
it("handles limit", function() { it("handles limit", function() {
Helpers.async(function(done) { Helpers.async(function(done) {
User.findAndCount({limit: 1})/*.on('sql', console.log)*/.success(function(info) { User.findAndCountAll({limit: 1})/*.on('sql', console.log)*/.success(function(info) {
expect(info.count).toEqual(fullcount) expect(info.count).toEqual(fullcount)
expect(Array.isArray(info.rows)).toBeTruthy() expect(Array.isArray(info.rows)).toBeTruthy()
expect(info.rows.length).toEqual(1) expect(info.rows.length).toEqual(1)
...@@ -284,7 +284,7 @@ describe('DAOFactory', function() { ...@@ -284,7 +284,7 @@ describe('DAOFactory', function() {
it("handles offset and limit", function() { it("handles offset and limit", function() {
Helpers.async(function(done) { Helpers.async(function(done) {
User.findAndCount({offset: 1, limit: 1}).success(function(info) { User.findAndCountAll({offset: 1, limit: 1}).success(function(info) {
expect(info.count).toEqual(fullcount) expect(info.count).toEqual(fullcount)
expect(Array.isArray(info.rows)).toBeTruthy() expect(Array.isArray(info.rows)).toBeTruthy()
expect(info.rows.length).toEqual(1) expect(info.rows.length).toEqual(1)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!