RangeError (end): Invalid value: Only valid value is 0: 1 when generating model - flutter

Getting the error RangeError (end): Invalid value: Only valid value is 0: 1 when generating model when I try to generate model
Expected Behavior
when I use this command get generate model on match_details with assets/models/to_get/match_details.json
it should be creating a model inside the match_details folder with the fields inside the JSON file mentioned.
Current Behavior
When I try to do this I get the error RangeError (end): Invalid value: Only valid value is 0: 1 when generating model** when I try to generate model
Possible Solution
Am sure it is something about parsing the JSON file
More info
here is what the JSON file looks like
{
"success": true,
"details": {
"id": 22,
"date_time": "2022-04-12T20:00:00Z",
"home_team": {
"id": 69,
"home_strip": {
"id": 15,
"image": "/uploads/strip_5_0py3QXM.png"
},
"away_strip": {
"id": 16,
"image": "/uploads/WhatsApp_Image_2022-03-09_at_10.24.56_AM.jpeg"
},
"players": [{
"id": 47,
"is_cap": false,
"average_skill": 3,
"region": {
"id": 13,
"name_ar": "التجمع الخامس",
"name_en": "Fifth Settlement",
"state": {
"id": 8,
"name_ar": "القاهره",
"name_en": "Cairo"
}
},
"first_name": "Ezz El Din",
"last_name": "Karim",
"mobile": "01113481110",
"email": null,
"image": null,
"positions_ar": [{
"مدافع": 3
}],
"positions_en": [{
"CB": 3
}],
"basic_skills_ar": [{
"السرعة": 4
},
{
"تمرير الكرة": 3
},
{
"تسديد": 2
}
],
"basic_skills_en": [{
"speeding": 4
},
{
"Passing": 3
},
{
"shooting": 2
}
]
}],
"cap": {
"id": 46,
"is_cap": true,
"average_skill": 3,
"region": {
"id": 13,
"name_ar": "التجمع الخامس",
"name_en": "Fifth Settlement",
"state": {
"id": 8,
"name_ar": "القاهره",
"name_en": "Cairo"
}
},
"first_name": "Karim",
"last_name": "Garrana",
"mobile": "01113332257",
"email": "karim.garrana#gmail.com",
"image": null,
"positions_ar": [{
"مهاجم": 3
},
{
"مدافع": 4
}
],
"positions_en": [{
"ST": 3
},
{
"CB": 4
}
],
"basic_skills_ar": [{
"السرعة": 3
},
{
"تمرير الكرة": 3
},
{
"تسديد": 3
}
],
"basic_skills_en": [{
"speeding": 3
},
{
"Passing": 3
},
{
"shooting": 3
}
]
},
"average_skill": 3,
"points": 0,
"name": "كوبرا",
"league": 25,
"logo": "/uploads/9_IApeihR.png",
"region_ar": "التجمع الخامس",
"region_en": "Fifth Settlement"
},
"away_team": {
"id": 68,
"home_strip": {
"id": 14,
"image": "/uploads/strip_6.png"
},
"away_strip": {
"id": 13,
"image": "/uploads/strip_5.png"
},
"players": [{
"id": 46,
"is_cap": true,
"average_skill": 3,
"region": {
"id": 13,
"name_ar": "التجمع الخامس",
"name_en": "Fifth Settlement",
"state": {
"id": 8,
"name_ar": "القاهره",
"name_en": "Cairo"
}
},
"first_name": "Karim",
"last_name": "Garrana",
"mobile": "01113332257",
"email": "karim.garrana#gmail.com",
"image": null,
"positions_ar": [{
"مهاجم": 3
},
{
"مدافع": 4
}
],
"positions_en": [{
"ST": 3
},
{
"CB": 4
}
],
"basic_skills_ar": [{
"السرعة": 3
},
{
"تمرير الكرة": 3
},
{
"تسديد": 3
}
],
"basic_skills_en": [{
"speeding": 3
},
{
"Passing": 3
},
{
"shooting": 3
}
]
}],
"cap": {
"id": 45,
"is_cap": false,
"average_skill": 4,
"region": {
"id": 11,
"name_ar": "ميامى",
"name_en": "Miami",
"state": {
"id": 7,
"name_ar": "الإسكندرية",
"name_en": "Alexandria"
}
},
"first_name": "Ahmed",
"last_name": "Wagdi",
"mobile": "01207199086",
"email": "ahmed.w.amin#gmail.com",
"image": "/uploads/90f1e1c9-b430-4f9c-8347-a86be57f58676954964268664537546.jpg",
"positions_ar": [{
"مدافع": 5
}],
"positions_en": [{
"CB": 5
}],
"basic_skills_ar": [{
"تسديد": 5
},
{
"تمرير الكرة": 5
},
{
"السرعة": 5
}
],
"basic_skills_en": [{
"shooting": 5
},
{
"Passing": 5
},
{
"speeding": 5
}
]
},
"average_skill": 4,
"points": 2,
"name": "المنتقمون",
"league": 25,
"logo": "/uploads/6.png",
"region_ar": "التجمع الخامس",
"region_en": "Fifth Settlement"
},
"location": {
"id": 8,
"name_ar": "مدرسة الكابيتال",
"name_en": "Capital School",
"location": "30.014650515430546,31.4582347869873",
"region": 13
}
}
}

Related

get Response from AWS step function after execution of each map iteration

I have an use case, where user is defined a workflow. As user hits the API, step function gets started. A lambda returns a list of steps based on users & start the workflow e.g.:
step1. it process(extracts) the doc,
step2. inserts some data to
DB
step3. .....
step4. .....
here steps are in map, as these steps are returned from lambda.
Is there any way to get response from each map iteration, so that I can show user at which step the process is , & the output of previous step.
here is my step function design:
test-fetch-input-workflow: returns an array: [step1, step2, ....]
workflow step-lambda: calls some lambda based on step name
Assuming that you are using Standard Workflows, you can get this information using the GetExecutionHistory API Action: https://docs.aws.amazon.com/step-functions/latest/apireference/API_GetExecutionHistory.html
You will want to look for events of type MapIterationSucceeded, grab the previousEventId, then look for the output in the HistoryEvent with that Id.
For example, if you had a state machine like this:
{
"StartAt": "Generate Array for Map",
"States": {
"Generate Array for Map": {
"Type": "Pass",
"Next": "Map",
"Result": [
1,
2,
3,
4,
5
]
},
"Map": {
"Type": "Map",
"ItemProcessor": {
"ProcessorConfig": {
"Mode": "INLINE"
},
"StartAt": "Generate Random Number",
"States": {
"Generate Random Number": {
"Type": "Pass",
"End": true,
"Parameters": {
"Random Number.$": "States.MathRandom(1,1000)"
}
}
}
},
"End": true
}
}
}
Your execution history would look like this:
{
"events": [
{
"timestamp": "2022-12-08T16:44:07.651000-08:00",
"type": "ExecutionStarted",
"id": 1,
"previousEventId": 0,
"executionStartedEventDetails": {
"input": "{\n \"Comment\": \"Insert your JSON here\"\n}",
"inputDetails": {
"truncated": false
},
"roleArn": "arn:aws:iam::000000000000:role/service-role/StepFunctions-MapTest-role-613230dd"
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateEntered",
"id": 2,
"previousEventId": 0,
"stateEnteredEventDetails": {
"name": "Generate Array for Map",
"input": "{\n \"Comment\": \"Insert your JSON here\"\n}",
"inputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateExited",
"id": 3,
"previousEventId": 2,
"stateExitedEventDetails": {
"name": "Generate Array for Map",
"output": "[1,2,3,4,5]",
"outputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapStateEntered",
"id": 4,
"previousEventId": 3,
"stateEnteredEventDetails": {
"name": "Map",
"input": "[1,2,3,4,5]",
"inputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapStateStarted",
"id": 5,
"previousEventId": 4,
"mapStateStartedEventDetails": {
"length": 5
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapIterationStarted",
"id": 6,
"previousEventId": 5,
"mapIterationStartedEventDetails": {
"name": "Map",
"index": 0
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapIterationStarted",
"id": 7,
"previousEventId": 5,
"mapIterationStartedEventDetails": {
"name": "Map",
"index": 1
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapIterationStarted",
"id": 8,
"previousEventId": 5,
"mapIterationStartedEventDetails": {
"name": "Map",
"index": 2
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapIterationStarted",
"id": 9,
"previousEventId": 5,
"mapIterationStartedEventDetails": {
"name": "Map",
"index": 3
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapIterationStarted",
"id": 10,
"previousEventId": 5,
"mapIterationStartedEventDetails": {
"name": "Map",
"index": 4
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateEntered",
"id": 11,
"previousEventId": 6,
"stateEnteredEventDetails": {
"name": "Generate Random Number",
"input": "1",
"inputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateExited",
"id": 12,
"previousEventId": 11,
"stateExitedEventDetails": {
"name": "Generate Random Number",
"output": "{\"Random Number\":259}",
"outputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapIterationSucceeded",
"id": 13,
"previousEventId": 12,
"mapIterationSucceededEventDetails": {
"name": "Map",
"index": 0
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateEntered",
"id": 14,
"previousEventId": 7,
"stateEnteredEventDetails": {
"name": "Generate Random Number",
"input": "2",
"inputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateExited",
"id": 15,
"previousEventId": 14,
"stateExitedEventDetails": {
"name": "Generate Random Number",
"output": "{\"Random Number\":776}",
"outputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapIterationSucceeded",
"id": 16,
"previousEventId": 15,
"mapIterationSucceededEventDetails": {
"name": "Map",
"index": 1
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateEntered",
"id": 17,
"previousEventId": 8,
"stateEnteredEventDetails": {
"name": "Generate Random Number",
"input": "3",
"inputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateExited",
"id": 18,
"previousEventId": 17,
"stateExitedEventDetails": {
"name": "Generate Random Number",
"output": "{\"Random Number\":743}",
"outputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapIterationSucceeded",
"id": 19,
"previousEventId": 18,
"mapIterationSucceededEventDetails": {
"name": "Map",
"index": 2
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateEntered",
"id": 20,
"previousEventId": 9,
"stateEnteredEventDetails": {
"name": "Generate Random Number",
"input": "4",
"inputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateExited",
"id": 21,
"previousEventId": 20,
"stateExitedEventDetails": {
"name": "Generate Random Number",
"output": "{\"Random Number\":790}",
"outputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapIterationSucceeded",
"id": 22,
"previousEventId": 21,
"mapIterationSucceededEventDetails": {
"name": "Map",
"index": 3
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateEntered",
"id": 23,
"previousEventId": 10,
"stateEnteredEventDetails": {
"name": "Generate Random Number",
"input": "5",
"inputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "PassStateExited",
"id": 24,
"previousEventId": 23,
"stateExitedEventDetails": {
"name": "Generate Random Number",
"output": "{\"Random Number\":632}",
"outputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapIterationSucceeded",
"id": 25,
"previousEventId": 24,
"mapIterationSucceededEventDetails": {
"name": "Map",
"index": 4
}
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapStateSucceeded",
"id": 26,
"previousEventId": 25
},
{
"timestamp": "2022-12-08T16:44:07.698000-08:00",
"type": "MapStateExited",
"id": 27,
"previousEventId": 25,
"stateExitedEventDetails": {
"name": "Map",
"output": "[{\"Random Number\":259},{\"Random Number\":776},{\"Random Number\":743},{\"Random Number\":790},{\"Random Number\":632}]",
"outputDetails": {
"truncated": false
}
}
},
{
"timestamp": "2022-12-08T16:44:07.745000-08:00",
"type": "ExecutionSucceeded",
"id": 28,
"previousEventId": 27,
"executionSucceededEventDetails": {
"output": "[{\"Random Number\":259},{\"Random Number\":776},{\"Random Number\":743},{\"Random Number\":790},{\"Random Number\":632}]",
"outputDetails": {
"truncated": false
}
}
}
]
}

Blazor Hybrid (MAUI) app works in iOS simulator, but not during App Review process

I recently finished developing my first Blazor Hybrid app. Everything went swimmingly. So I submitted it to the store and got back a rejection saying it crashes on start. The crash dump was very uninformative and I don't really know what to do next.The Android version is already published and running perfectly on Android phones. Below is the crash dump that Apple made available. I won't bother posting the csproj, because it's basically unchanged from when I created it using VS 2022 Preview. Of course I added some dependencies, but that's about it.
Can anyone please help me diagnose this? Is there a way to run on a real iPhone using VS 2022 Preview for Mac?
How might I get an actual stack if I were to submit a new version Apple? Any why does the dump not contain a stack?
Edit: got it running on a physical iPad and I get the same exact crash report as below. No actual stack or anything remotely symbolicated. Anyone know why?
Here is the relevant publish section from the csproj:
<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
<CodesignProvision>Automatic</CodesignProvision>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<CodesignKey>iPhone Distribution</CodesignKey>
<DebugType>none</DebugType>
<Optimize>True</Optimize>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause>
<MtouchArch>ARMv7, ARM64</MtouchArch>
<MtouchLink>SdkOnly</MtouchLink>
</PropertyGroup>
And here is the "dump" with sensitive stuff taken out:
{
"app_name": "xxx",
"timestamp": "2022-08-17 09:48:02.00 -0700",
"app_version": "2.0.2",
"slice_uuid": "c4517caa-e8a8-33db-aeff-35bea44c52c7",
"adam_id": "1498333673",
"build_version": "202",
"platform": 2,
"bundleID": "xxx",
"share_with_app_devs": 0,
"is_first_party": 0,
"bug_type": "309",
"os_version": "iPhone OS 15.6 (19G71)",
"incident_id": "49BECBB4-1A4A-48D8-AC7A-72744145E305",
"name": "xxx"
}
{
"uptime": 410000,
"procLaunch": "2022-08-17 09:48:01.7292 -0700",
"procRole": "Foreground",
"version": 2,
"userID": 501,
"deployVersion": 210,
"modelCode": "iPad11,3",
"procStartAbsTime": 10024794259695,
"coalitionID": 844,
"osVersion": {
"isEmbedded": true,
"train": "iPhone OS 15.6",
"releaseType": "User",
"build": "19G71"
},
"captureTime": "2022-08-17 09:48:01.8504 -0700",
"incident": "49BECBB4-1A4A-48D8-AC7A-72744145E305",
"bug_type": "309",
"pid": 43760,
"procExitAbsTime": 10024797152548,
"cpuType": "ARM-64",
"procName": "xxx",
"procPath": "\/private\/var\/containers\/Bundle\/Application\/7017F8DA-1FAD-4DDE-BCC5-F7981C60C973\/xxx",
"bundleInfo": {
"CFBundleShortVersionString": "2.0.2",
"CFBundleVersion": "202",
"CFBundleIdentifier": "xxx",
"DTAppStoreToolsBuild": "13F100"
},
"storeInfo": {
"itemID": "1498333673",
"deviceIdentifierForVendor": "39D05405-6205-4451-9244-34FFEEC95A57",
"thirdParty": true,
"softwareVersionExternalIdentifier": "851585260"
},
"parentProc": "launchd",
"parentPid": 1,
"coalitionName": "xxx",
"crashReporterKey": "5c0b0236026542e0d88176f980a207075623f495",
"isCorpse": 1,
"exception": {
"codes": "0x0000000000000000, 0x0000000000000000",
"rawCodes": [
0,
0
],
"type": "EXC_CRASH",
"signal": "SIGABRT"
},
"asi": {
"libsystem_c.dylib": [
"abort() called"
]
},
"faultingThread": 0,
"threads": [
{
"triggered": true,
"id": 1576930,
"threadState": {
"x": [
{
"value": 0
},
{
"value": 0
},
{
"value": 0
},
{
"value": 0
},
{
"value": 0
},
{
"value": 10000000
},
{
"value": 28
},
{
"value": 768
},
{
"value": 9797698587401187317
},
{
"value": 9797698591528184437
},
{
"value": 1000
},
{
"value": 2045
},
{
"value": 54
},
{
"value": 2407608375
},
{
"value": 2409707520
},
{
"value": 39
},
{
"value": 328
},
{
"value": 4463068544,
"symbolLocation": 0,
"symbol": "_main_thread"
},
{
"value": 0
},
{
"value": 6
},
{
"value": 259
},
{
"value": 4463068768,
"symbolLocation": 224,
"symbol": "_main_thread"
},
{
"value": 12
},
{
"value": 27280
},
{
"value": 18446744073709551615
},
{
"value": 4457047756
},
{
"value": 1056
},
{
"value": 4551975392
},
{
"value": 4530786760
}
],
"flavor": "ARM_THREAD_STATE64",
"lr": {
"value": 8342680508
},
"cpsr": {
"value": 1073741824
},
"fp": {
"value": 6102932768
},
"sp": {
"value": 6102932736
},
"esr": {
"value": 1442840704,
"description": " Address size fault"
},
"pc": {
"value": 7384791864,
"matchesCrashFrame": 1
},
"far": {
"value": 4530305400
}
},
"name": "tid_103",
"queue": "com.apple.main-thread",
"frames": [
{
"imageOffset": 31544,
"symbol": "__pthread_kill",
"symbolLocation": 8,
"imageIndex": 0
},
{
"imageOffset": 29628,
"symbol": "pthread_kill",
"symbolLocation": 268,
"imageIndex": 1
},
{
"imageOffset": 492620,
"symbol": "__abort",
"symbolLocation": 128,
"imageIndex": 2
},
{
"imageOffset": 132400,
"symbol": "abort",
"symbolLocation": 180,
"imageIndex": 2
},
{
"imageOffset": 83099388,
"imageIndex": 3
},
{
"imageOffset": 86072624,
"imageIndex": 3
},
{
"imageOffset": 86072932,
"imageIndex": 3
},
{
"imageOffset": 85666320,
"imageIndex": 3
},
{
"imageOffset": 84529256,
"imageIndex": 3
},
{
"imageOffset": 84527808,
"imageIndex": 3
},
{
"imageOffset": 84535064,
"imageIndex": 3
},
{
"imageOffset": 83132492,
"imageIndex": 3
},
{
"imageOffset": 84535924,
"imageIndex": 3
},
{
"imageOffset": 84525344,
"imageIndex": 3
},
{
"imageOffset": 85701052,
"imageIndex": 3
},
{
"imageOffset": 85666228,
"imageIndex": 3
},
{
"imageOffset": 84529256,
"imageIndex": 3
},
{
"imageOffset": 84527808,
"imageIndex": 3
},
{
"imageOffset": 84535064,
"imageIndex": 3
},
{
"imageOffset": 83097272,
"imageIndex": 3
},
{
"imageOffset": 83133596,
"imageIndex": 3
},
{
"imageOffset": 86087812,
"imageIndex": 3
},
{
"imageOffset": 105892,
"symbol": "start",
"symbolLocation": 520,
"imageIndex": 4
}
]
},
{
"id": 1576933,
"frames": [
{
"imageOffset": 3668,
"symbol": "start_wqthread",
"symbolLocation": 0,
"imageIndex": 1
}
]
},
{
"id": 1576934,
"name": "SGen worker",
"frames": [
{
"imageOffset": 7972,
"symbol": "__psynch_cvwait",
"symbolLocation": 8,
"imageIndex": 0
},
{
"imageOffset": 33432,
"symbol": "_pthread_cond_wait",
"symbolLocation": 1236,
"imageIndex": 1
},
{
"imageOffset": 85559788,
"imageIndex": 3
},
{
"imageOffset": 6572,
"symbol": "_pthread_start",
"symbolLocation": 148,
"imageIndex": 1
},
{
"imageOffset": 3688,
"symbol": "thread_start",
"symbolLocation": 8,
"imageIndex": 1
}
]
}
],
"usedImages": [
{
"source": "P",
"arch": "arm64e",
"base": 7384760320,
"size": 221184,
"uuid": "9ab02ad0-348c-30cb-99f4-0979c2d47515",
"path": "\/usr\/lib\/system\/libsystem_kernel.dylib",
"name": "libsystem_kernel.dylib"
},
{
"source": "P",
"arch": "arm64e",
"base": 8342650880,
"size": 49152,
"uuid": "a8989ffb-1414-39dc-a1a8-1534f21923fe",
"path": "\/usr\/lib\/system\/libsystem_pthread.dylib",
"name": "libsystem_pthread.dylib"
},
{
"source": "P",
"arch": "arm64e",
"base": 6649233408,
"size": 524288,
"uuid": "86a1a24a-ce35-3769-ba69-60f28353281e",
"path": "\/usr\/lib\/system\/libsystem_c.dylib",
"name": "libsystem_c.dylib"
},
{
"source": "P",
"arch": "arm64",
"base": 4363943936,
"size": 89866240,
"uuid": "c4517caa-e8a8-33db-aeff-35bea44c52c7",
"path": "\/private\/var\/containers\/Bundle\/Application\/7017F8DA-1FAD-4DDE-BCC5-F7981C60C973\/xxx",
"name": "xxx"
},
{
"source": "P",
"arch": "arm64e",
"base": 4462624768,
"size": 360448,
"uuid": "66e1fb26-68f8-379b-a052-eb8b8291b5e1",
"path": "\/usr\/lib\/dyld",
"name": "dyld"
}
],
"sharedCache": {
"base": 6459588608,
"size": 2509930496,
"uuid": "c5fbbd80-45de-3edf-969b-119fca42580a"
},
"vmSummary": "ReadOnly portion of Libraries: Total=810.9M resident=0K(0%) swapped_out_or_unallocated=810.9M(100%)\nWritable regions: Total=587.4M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=587.4M(100%)\n\n VIRTUAL REGION \nREGION TYPE SIZE COUNT (non-coalesced) \n=========== ======= ======= \nActivity Tracing 256K 1 \nColorSync 32K 2 \nKernel Alloc Once 32K 1 \nMALLOC 564.2M 93 \nMALLOC guard page 64K 4 \nSTACK GUARD 48K 3 \nStack 2096K 3 \nVM_ALLOCATE 10.6M 18 \nVM_ALLOCATE (reserved) 8192K 1 reserved VM address space (unallocated)\n__AUTH 3816K 409 \n__AUTH_CONST 21.3M 551 \n__CTF 756 1 \n__DATA 16.5M 542 \n__DATA_CONST 21.9M 559 \n__DATA_DIRTY 2067K 465 \n__FONT_DATA 4K 1 \n__LINKEDIT 187.4M 3 \n__OBJC_CONST 5299K 379 \n__OBJC_RO 91.3M 1 \n__OBJC_RW 3472K 1 \n__TEXT 623.5M 567 \n__UNICODE 592K 1 \ndyld private memory 1024K 1 \nmapped file 15.0M 127 \nshared memory 32K 2 \n=========== ======= ======= \nTOTAL 1.5G 3736 \nTOTAL, minus reserved VM space 1.5G 3736 \n",
"legacyInfo": {
"threadTriggered": {
"name": "tid_103",
"queue": "com.apple.main-thread"
}
},
"trialInfo": {
"rollouts": [
{
"rolloutId": "5ffde50ce2aacd000d47a95f",
"factorPackIds": {},
"deploymentId": 240000179
},
{
"rolloutId": "610d4ab6fc54bc33898403cd",
"factorPackIds": {
"SIRI_UNDERSTANDING_MORPHUN": "6201e7dc295c182621ecf027"
},
"deploymentId": 240000257
}
],
"experiments": [
{
"treatmentId": "06dd09ac-4929-4c36-8aa5-454eba81318c",
"experimentId": "60cb9b8392f6a873b12a8ba6",
"deploymentId": 400000038
}
]
}
}

how to update the first object in the array of quarterFinals that matches some mongoDB condition?

I have the document below and I need to iterate through the quarterFinals array and update the first null address property I find to '123'
{
"data": {
"createTournament": {
"_id": "613122d0c7befdeef3b0b571",
"title": "Jogo de truco",
"description": "",
"location": "Batalha na rua",
"type": "Battle",
"players": [],
"status": "PENDING",
"size": 8,
"entryFee": 1,
"prizePool": 20,
"currency": "USD",
"startDate": "2021-09-01",
"endDate": "2021-09-01",
"rounds": {
"quarterFinals": [{
"id": "9fb6f9ca-c06a-4972-b140-0f2425a90707",
"arena": "",
"firstParticipant": {
"address": null,
"battlesWon": 0
},
"secondParticipant": {
"address": null,
"battlesWon": 0
}
}]
}
}
}
}
One way of doing this is
exports.updateData = async (tournamentID,address)=>{
return await db_collection.updateOne({id:tournamentId,rounds:{$elemMatch:{quarterfinals.address:null}}},{$push:{address:address});
};

AWS API Gateway Model Schema for table display on website

I want to display data from a API call on a Wordpress table. Most table plug-ins accept JSON results from an API call but only if it's formatted as follows
[
{
"stockId": 4,
"description": "Powerbanks",
"costPrice": 42,
"salePrice": 80,
"units": 10,
"purchaseDate": "2019-09-27T00:00:00.000Z",
"image": "power bank.jpg",
"supplierId": 0
},
{
"stockId": 8,
"description": "Chip",
"costPrice": 0.5,
"salePrice": 1.5,
"units": 49,
"purchaseDate": "2019-09-27T00:00:00.000Z",
"image": "Chip.jpg",
"supplierId": 0
},
{
"stockId": 9,
"description": "Honey",
"costPrice": 5.6,
"salePrice": 66,
"units": 33,
"purchaseDate": "2019-09-27T00:00:00.000Z",
"image": "honey.jpg",
"supplierId": 0
}
]
What JSON schema do I need to format the data like this? The JSON output starts/ends with [ ]
My current model schema looks like this at the moment
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Get all stock",
"type": "object",
"properties": {
"rows": {
"type": "array",
"items" : {
"type" : "object",
"properties": {
"stockId": { "type": "number" },
"description": { "type": "string" },
"costPrice": { "type": "number" },
"salePrice": { "type": "number" },
"units": { "type": "number" },
"purchaseDate": { "type": "string" },
"image" : { "type" : "string" },
"supplierId": { "type": "number" }
}
}
}
}
}
This gives the following output:
{
"rows": [
{
"stockId": 4,
"description": "Powerbanks",
"costPrice": 42,
"salePrice": 80,
"units": 10,
"purchaseDate": "2019-09-27T00:00:00.000Z",
"image": "power bank.jpg",
"supplierId": 0
},
{
"stockId": 8,
"description": "Chip",
"costPrice": 0.5,
"salePrice": 1.5,
"units": 49,
"purchaseDate": "2019-09-27T00:00:00.000Z",
"image": "Chip.jpg",
"supplierId": 0
},
{
"stockId": 9,
"description": "Honey",
"costPrice": 5.6,
"salePrice": 66,
"units": 33,
"purchaseDate": "2019-09-27T00:00:00.000Z",
"image": "honey.jpg",
"supplierId": 0
}
]
}
How do I change the model schema to look like the output needed?

How to update a part of an array sub document in MongoDB

I have this document in my mongodb collection:
{
"_id": "YLRM9Wi7f6tp6qNbS",
"sessionId": "hLDkkJKR4Muik6tbe",
"userId": "ZYoG4cH8HcCDPMDGr",
"shopId": "J8Bhq3uTtdgwZx3rz",
"workflow": {
"status": "",
"workflow": ["String"]
},
"billing": [Object],
"discount": 0,
"tax": 0,
"items": [
{
"_id": "JwR233jD2c4HKeYKq",
"shopId": "J8Bhq3uTtdgwZx3rz",
"productId": "BCTMZ6HTxFSppJESk",
"quantity": 1,
"product": {
"_id": "BCTMZ6HTxFSppJESk",
"title": "Product",
"shopId": "J8Bhq3uTtdgwZx3rz",
"ancestors": [],
"createdAt": "2018-01-12T10:22:18.853Z",
"description": "",
"handle": "product",
"hashtags": [
"rpjCvTBGjhBi2xdro",
"cseCBSSrJ3t8HQSNP"
],
"price": {
"range": "12.99 - 19.99",
"min": 12.99,
"max": 19.99
},
"isVisible": true,
"isLowQuantity": false,
"isSoldOut": false,
"isBackorder": false,
"metafields": [
{
"key": "Material",
"value": "Cotton"
},
{
"key": "Quality",
"value": "Excellent"
}
],
"pageTitle": "",
"type": "simple",
"updatedAt": "2018-01-12T10:22:18.854Z",
"vendor": "Vendor_Name",
"originCountry": "country",
"requiresShipping": true,
"isDeleted": false,
"template": "productDetailSimple",
"workflow": {
"status": "new"
}
},
"variants": {},
"title": "Product",
"type": "simple",
"parcel": {
"weight": 25,
"height": 3,
"width": 10,
"length": 10
},
"shippingMethod": {
"shopId": "J8Bhq3uTtdgwZx3rz",
"shipmentQuotes": [Object],
"shipmentQuotesQueryStatus": {
"requestStatus": "success",
"numOfShippingMethodsFound": 11
},
"_id": "s3EJXrLsZe73RbLiD",
"address": {},
"shipmentMethod": {},
"paymentId": "nyybR5BNvDDrJrtwe",
"items": [
{
"_id": "JwR233jD2c4HKeYKq",
"productId": "BCTMZ6HTxFSppJESk",
"shopId": "J8Bhq3uTtdgwZx3rz",
"variantId": "CJoRBm9vRrorc9mxZ"
}
],
"workflow": {
"status": "new",
"workflow": ["String"]
}
},
"workflow": {
"status": "new",
"workflow": ["String"]
}
}
],
"shipping": [Object],
"email": "johndoe#mail.com",
"cartId": "L6sSGv4NR9rpbDbsd",
"createdAt": "2018-01-12T10:22:18.850Z"
}
The field items is an array of objects, I would like to update just a part of the object specifically the workflow field without touching other part of the objects in items array.
I was able to do this using a loop, but it caused some tests to fail. Is there a better of doing this with using a loop?
Thank you.
You can try findAndModify method.
Traverse to the workflow key ad try to set the value.
Hope this would help.