javascript - Query entire class vs first object in the class -
javascript - Query entire class vs first object in the class -
in cloud code want retrieve first object in "messages" class. want grab info object, send class, , delete object "messages" class pulled from.
my question need query entire "messages" class first object in it? don't want slow downwards app due inefficient code.
parse.cloud.aftersave("sendmessage", function(parse.message, response) { var body = null; var sendername = null; var senderid = null; var randusers = []; var query = new.parse.query(parse.message); query.find({ success: function(results){ body.push(results[1].get("messagebody")); sendername.push(results[1].get("sendername")); senderid.push(results[1].get("senderid")); response.success(getusers); }, error: funtion(error){ response.error("error"); } }); });
to avoid confusion: "getusers" arbitrary function call.
to retrieve entry class, need query table. however, problem getting first record not require getting record. code can see first record of result array (result[1] ). can apply solution; getting first record of class want query. can via 2 ways; either can set limit 1 query or can utilize first() method. parse.query js api link below;
https://parse.com/docs/js/symbols/parse.query.html
check limit , first methods. hope helps. regards.
javascript parse.com cloud-code
Comments
Post a Comment