Skip to content

Commit cbfee37

Browse files
committed
Fixed issue #82.
1 parent b5a0650 commit cbfee37

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

lib/query.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,17 @@
387387
return this;
388388
},
389389

390+
/**
391+
* Add a constraint to the query that requires a particular
392+
* <strong>array</strong> key's length to be equal to the provided value.
393+
* @param {String} key The array key to check.
394+
* @param value The length value.
395+
* @return {AV.Query} Returns the query, so you can chain this call.
396+
*/
397+
sizeEqualTo: function(key, value) {
398+
this._addCondition(key, "$size", value);
399+
},
400+
390401
/**
391402
* Add a constraint to the query that requires a particular key's value to
392403
* be not equal to the provided value.

test/query.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,25 @@ describe("Queries",function(){
141141
throw error;
142142
}
143143
});
144+
145+
146+
it("sizeEqualTo",function(done){
147+
var gameScore = new GameScore();
148+
gameScore.save({
149+
players: ["a", "b"]
150+
}).then(function() {
151+
query = new AV.Query(GameScore);
152+
query.sizeEqualTo("players", 2);
153+
query.first({
154+
success: function(object) {
155+
expect(object.get('players').size).to.be(2);
156+
done();
157+
},
158+
error: function(error) {
159+
throw error;
160+
}
161+
});
162+
});
144163
});
145164
});
146165

0 commit comments

Comments
 (0)