Last active
September 25, 2015 16:19
-
-
Save jeffhuangtw/751178dd0c3873449747 to your computer and use it in GitHub Desktop.
dirty sample for Parse Job query.each and push something
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 queryAllUser = new Parse.Query(Parse.User); | |
Parse.Cloud.useMasterKey(); | |
queryAllUser.each(function(user) { | |
var queryMatch = new Parse.Query(Parse.User); | |
queryMatch.containedIn("offer", user.get("search")); | |
return query.find().then(function(users) { | |
if (users.length >0) { | |
var targetList = []; | |
for (i = 0; i < users.length; i++) { | |
var userPointer = Parse.Object.extend(Parse.User); | |
userPointer = EVENT.createWithoutData(users[i].id); | |
targetList.push(userPointer); | |
} | |
// | |
var queryTarget = new Parse.Query(Parse.Installation); | |
queryTarget.equalTo('user', targetList); | |
return Parse.Push.send({ | |
where: queryTarget, | |
data: { | |
alert: {"loc-key": "NOTIFICATION_MATCH_SKILL", "loc-args": []}, | |
badge: "Increment", | |
action: "com.xxxx.yyyapp.MATCH_SKILL", | |
type: "MATCH_SKILL | |
} | |
}) | |
} else { | |
console.log("..no match for user:" + user.id); | |
return new Parse.Promise().resolve("no mtach"); | |
} | |
}).then(function() { | |
console.log("..after check match"); | |
}, function(error) { | |
console.log("..something wrong" + error.message); | |
}); | |
}).then(function() { | |
status.success("batch job done"); | |
}, function(error) { | |
status.error("batch job error:" + error.message); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Debugged the Code, but have this error now..
Result: batch job error:
I2015-09-25T16:14:05.101Z]..something wrongequality needs a value instead of [map[objectId:0PhcMvmTVb __type:Pointer className:_User] map[__type:Pointer className:_User objectId:1KnCQEAPV6] map[__type:Pointer className:_User objectId:6texel7doI] map[className:_User objectId:8H4zryKYGL __type:Pointer] map[objectId:93yJ8nxtgM __type:Pointer className:_User] map[__type:Pointer className:_User objectId:Ba8D7XOgMo] map[__type:Pointer className:_User objectId:D0BVscgasC] map[__type:Pointer className:_User objectId:Jx9vwGj1sq] map[__type:Pointer className:_User objectId:SVWA9WUFkB] map[__type:Pointer className:_User objectId:SoONai33Uz] map[__type:Pointer className:_User objectId:UzUOkXNoIq] map[__type:Pointer className:_User objectId:bL8jqxAosi] map[__type:Pointer className:_User objectId:n0LTebrRoR] map[className:_User objectId:ujhhOWjk1n __type:Pointer] map[objectId:P5cmRgibpk __type:Pointer className:_User] map[__type:Pointer className:_User objectId:XKPgDAts6u] map[__type:Pointer className:_User ... (truncated)