Created
May 5, 2012 00:07
-
-
Save ericktai/2598642 to your computer and use it in GitHub Desktop.
JS New SDK Features May 2012
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var users = new StackMob.Users(); | |
users.count(null, { | |
success: function(count) { | |
//count is an integer representing number of all users | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var q = new StackMob.Collection.Query(); | |
q.lt('age', 35); | |
q.gte('follower_count', 20); | |
var users = new StackMob.Users(); | |
users.count(q, { | |
success: function(count) { | |
//count is an integer representing number of users of age < 35 and follower_count >=20 | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var q = new StackMob.Collection.Query(); | |
q.lt('age', 35); | |
q.gte('follower_count', 20); | |
var users = new StackMob.Users(); | |
users.count(q, { | |
success: function(count) { | |
//count is an integer representing number of users of age < 35 and follower_count >=20 | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
StackMob.isLoggedIn(); //true or false | |
StackMob.isUserLoggedIn('bob'); //true or false | |
StackMob.getLoggedInUser(); //bob | |
var user = new StackMob.User({ username: 'bob' }); | |
user.isLoggedIn() //true or false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var q = new StackMob.Collection.Query(); | |
q.notEquals('account_status', 'closed'); | |
q.isNull('account'); | |
q.isNotNull('email'); | |
var users = new StackMob.Users(); | |
users.query(q, { | |
success: function(results) { | |
//list of users that match | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment