Created
March 13, 2015 04:25
-
-
Save fxp/7e384eaa46dc3102f6c7 to your computer and use it in GitHub Desktop.
Get all possible value of a certain field from Leancloud
This file contains 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 getAllValues = function (className, fieldName) { | |
var promise = new AV.Promise(); | |
var TargetClass = AV.Object.extend(className); | |
var values = []; | |
var getNextValue = function () { | |
var query = new AV.Query(TargetClass); | |
query.notContainedIn(values); | |
query.first().then(function (obj) { | |
if (obj) { | |
values.push(obj.get(fieldName)); | |
getNextValue() | |
} else { | |
promise.resolve(values); | |
} | |
}) | |
} | |
return promise; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
var getAllValues = function (className, fieldName) {
var promise = new AV.Promise();
}
求PR