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

Commit e4849adb by Sascha Depold

attribute aliasing

1 parent 7d8eee95
Showing with 18 additions and 0 deletions
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
- [FEATURE] Association definition is chainable: Person.hasOne(House).hasMany(Address) - [FEATURE] Association definition is chainable: Person.hasOne(House).hasMany(Address)
- [FEATURE] Validations (Thanks to [hiddentao](https://github.com/hiddentao)) - [FEATURE] Validations (Thanks to [hiddentao](https://github.com/hiddentao))
- [FEATURE] jQuery-like event listeners: .success(callback) and .error(callback) - [FEATURE] jQuery-like event listeners: .success(callback) and .error(callback)
- [FEATURE] aliasing for select queries: Model.find({ where: 'id = 1', attributes: ['id', ['name', 'username']] }) ==> will return the user's name as username
# v1.2.1 # # v1.2.1 #
- [REFACTORING] renamed the global options for sync, query and define on sequelize; before: options.queryOptions; now: options.query - [REFACTORING] renamed the global options for sync, query and define on sequelize; before: options.queryOptions; now: options.query
......
...@@ -9,6 +9,23 @@ describe('ModelFactory', function() { ...@@ -9,6 +9,23 @@ describe('ModelFactory', function() {
var User = sequelize.define('User', { age: Sequelize.INTEGER, name: Sequelize.STRING, bio: Sequelize.TEXT }) var User = sequelize.define('User', { age: Sequelize.INTEGER, name: Sequelize.STRING, bio: Sequelize.TEXT })
//////////// find //////////////
describe('.find', function() {
beforeEach(function() {
Helpers.Factories.User({name: 'user', bio: 'foobar'}, null, 2)
})
it("should make aliased attributes available", function() {
Helpers.async(function(done) {
User.find({ where: 'id = 1', attributes: ['id', ['name', 'username']] }).success(function(user) {
expect(user.username).toEqual('user')
done()
})
})
})
})
//////////// all ////////////// //////////// all //////////////
describe('.all', function() { describe('.all', function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!