downstairs
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -89,5 +89,5 @@ var Table = {} | ||
// if (conditions.queryParameters.orderBy){ | ||
// sqlStr.text = sqlStr.text + " ORDER BY " + conditions.queryParameters['orderBy']; | ||
// } | ||
if (conditions.queryParameters.orderBy){ | ||
sqlStr.text = sqlStr.text + " ORDER BY " + conditions.queryParameters['orderBy']; | ||
} | ||
} | ||
@@ -94,0 +94,0 @@ |
{ | ||
"name": "downstairs", | ||
"description": "A light ORM wrapped about brianc's node-sql and node-pg", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"homepage": "https://github.com/moneytribeaustralia/downstairs.js", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -62,3 +62,3 @@ var pg = require('pg') | ||
exports.repeatableSQL = "CREATE TABLE repeatables\ | ||
exports.repeatableTableSQL = "CREATE TABLE repeatables\ | ||
(\ | ||
@@ -65,0 +65,0 @@ id serial NOT NULL,\ |
@@ -270,32 +270,36 @@ var Downstairs = require('../lib/downstairs') | ||
beforeEach(function(done){ | ||
helper.resetDb(helper.repeatableSQL, done); | ||
helper.resetDb(helper.repeatableTableSQL + helper.userTableSQL, done); | ||
}) | ||
var firstRepeatable, secondRepeatable, thirdRepeatable; | ||
describe('limit', function(done){ | ||
beforeEach(function(done){ | ||
Repeatable.create({name: 'blue'}, function(err, repeatable){ | ||
firstRepeatable = repeatable; | ||
var firstRepeatable, secondRepeatable, thirdRepeatable; | ||
beforeEach(function(done){ | ||
Repeatable.create({name: 'blue'}, function(err, repeatable){ | ||
secondRepeatable = repeatable; | ||
firstRepeatable = repeatable; | ||
Repeatable.create({name: 'blue'}, function(err, repeatable){ | ||
thirdRepeatable = repeatable; | ||
// Repeatable.findAll({}, function(err, repeatables){ | ||
// console.log(repeatables.length, " <<<<<"); | ||
// }) | ||
done(); | ||
secondRepeatable = repeatable; | ||
Repeatable.create({name: 'blue'}, function(err, repeatable){ | ||
thirdRepeatable = repeatable; | ||
// Repeatable.findAll({}, function(err, repeatables){ | ||
// console.log(repeatables.length, " <<<<<"); | ||
// }) | ||
done(); | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
it('parses limit in queryParameters of conditions', function(done) { | ||
var data = {queryParameters: { limit: 2 } }; | ||
it('parses limit in queryParameters of conditions', function(done) { | ||
var data = {queryParameters: { limit: 2 } }; | ||
Repeatable.findAll(data, function(err, repeatables){ | ||
repeatables.length.should.equal(2); //if it's 3, we have an error with limit | ||
done(); | ||
Repeatable.findAll(data, function(err, repeatables){ | ||
repeatables.length.should.equal(2); //if it's 3, we have an error with limit | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}) | ||
// it('parses offset in queryParameters of conditions', function(done) { | ||
@@ -310,2 +314,35 @@ // var data = { queryParameters: { offset: 2 } }; | ||
// }); | ||
describe('order by', function(done){ | ||
var User = Table.model('User', userSQL); | ||
beforeEach(function(done){ | ||
var data = {password: '5f4dcc3b5aa765d61d8327deb882cf99', username: 'andrew', email: 'andrew@moneytribe.com.au'}; | ||
ectypes.User.create(data, function(err, results) { | ||
var data = {password: '5f4dcc3b5aa765d61d8327deb882cf99', username: 'zack', email: 'zack@moneytribe.com.au'}; | ||
ectypes.User.create(data, function(err, results) { | ||
done() | ||
}) | ||
}) | ||
}) | ||
it('parses order by DESC', function(done) { | ||
User.findAll({queryParameters: {orderBy: 'username DESC'}}, function(err, users){ | ||
users[0].username.should.equal('zack'); | ||
users[1].username.should.equal('andrew'); | ||
done() | ||
}); | ||
}); | ||
it('parses order by ASC', function(done) { | ||
User.findAll({queryParameters: {orderBy: 'username ASC'}}, function(err, users){ | ||
users[0].username.should.equal('andrew'); | ||
users[1].username.should.equal('zack'); | ||
done() | ||
}); | ||
}); | ||
}) | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52982
1222