Hi,
I would like to investigate query performance and was able to set a simple function that returns array of objects.
Parse.Cloud.define("newProfiles", async (request) => {
const basicQuery = new Parse.Query("PrsProfile");
basicQuery.lessThanOrEqualTo("ag", 26);
basicQuery.greaterThanOrEqualTo("ag", 23);
const results = await basicQuery.find({ sessionToken: request.user.getSessionToken() });
return results;
});
This works as intended and I have PrsProfile object already as a struct, so decoding is not an issue. But when I chain basicQuery.explain()
in to the function, it returns result that I canât read well:
error: The data couldnât be read because it isnât in the correct format. Format: Optional("{\âresult\â:{\âqueryPlanner\â:{\âmongosPlannerVersion\â:1,\âwinningPlan\â:{\âstage\â:\âSINGLE_SHARD\â,\âshards\â:[{\âshardName\â:\ârs6\â,\âconnectionString\â:\ârs6/MongoRS601A.back4app.com:27018,MongoRS602A.back4app.com:27018\â,\âserverInfo\â:{\âhost\â:\âMongoRS601A.back4app.com\â,\âport\â:27018,\âversion\â:\â3.6.8-2.0\â,\âgitVersion\â:\â1fb3fbd45602ef799b4053edbe1f2748ab97eebe\â},\âplannerVersion\â:1,\ânamespace\â:\âa1b5c903c7814f7a836a269dc63ff84f.PrsProfile\â,\âindexFilterSet\â:false,\âparsedQuery\â:{\"$and\":[{\âag\â:{\"$lte\":26}},{\âag\â:{\"$gte\":23}},{\"_rperm\":{\"$in\":[null,\"\",\âzyLHKLV5Ll\â]}}]},\âwinningPlan\â:{\âstage\â:\âLIMIT\â,\âlimitAmount\â:100,\âinputStage\â:{\âstage\â:\âCOLLSCAN\â,\âfilter\â:{\"$and\":[{\âag\â:{\"$lte\":26}},{\âag\â:{\"$gte\":23}},{\"_rperm\":{\"$in\":[null,\"\",\âzyLHKLV5Ll\â]}}]},\âdirection\â:\âforward\â}},\ârejectedPlans\â:}]}},\âexecutionStats\â:{\ânReturned\â:1,\âexecutionTimeMillis\â:3,\âtotalKeysExamined\â:0,\âtotalDocsExamined\â:1,\âexecutionStages\â:{\âstage\â:\âSINGLE_SHARD\â,\ânReturned\â:1,\âexecutionTimeMillis\â:3,\âtotalKeysExamined\â:0,\âtotalDocsExamined\â:1,\âtotalChildMillis\â:0,\âshards\â:[{\âshardName\â:\ârs6\â,\âexecutionSuccess\â:true,\âexecutionStages\â:{\âstage\â:\âLIMIT\â,\ânReturned\â:1,\âexecutionTimeMillisEstimate\â:0,\âworks\â:3,\âadvanced\â:1,\âneedTime\â:1,\âneedYield\â:0,\âsaveState\â:0,\ârestoreState\â:0,\âisEOF\â:1,\âinvalidates\â:0,\âlimitAmount\â:100,\âinputStage\â:{\âstage\â:\âCOLLSCAN\â,\âfilter\â:{\"$and\":[{\âag\â:{\"$lte\":26}},{\âag\â:{\"$gte\":23}},{\"_rperm\":{\"$in\":[null,\"*\",\âzyLHKLV5Ll\â]}}]},\ânReturned\â:1,\âexecutionTimeMillisEstimate\â:0,\âworks\â:3,\âadvanced\â:1,\âneedTime\â:1,\âneedYield\â:0,\âsaveState\â:0,\ârestoreState\â:0,\âisEOF\â:1,\âinvalidates\â:0,\âdirection\â:\âforward\â,\âdocsExamined\â:1}}}]},\âallPlansExecution\â:[{\âshardName\â:\ârs6\â,\âallPlans\â:}]},\âok\â:1}}")")
I am using following definition with ParseSwift SDK:
let findQuery = Cloud(functionJobName: "newProfiles")
findQuery.runFunction { result in
switch result {
case .success(let results):
print("Response from cloud function: \(results))")
case .failure(let error):
print("Error calling cloud function: \(error)")
}
}
The typealias in the Cloud struct is for me the unknownâŚ
import** ParseSwift
//: Create your own value typed `ParseCloud` type.
struct** Cloud: ParseCloud {
//: Return type of your Cloud Function
typealias ReturnType = ????
//: These are required for Object
var functionJobName: String
}
Does anyone has a wrapper or useful trick, how to print explain() result in Xcode in a better way?
Thank you!