diff --git a/force-app/main/default/classes/Bolt.cls b/force-app/main/default/classes/Bolt.cls index dc4fe37..7b1fa5b 100644 --- a/force-app/main/default/classes/Bolt.cls +++ b/force-app/main/default/classes/Bolt.cls @@ -1,12 +1,24 @@ public with sharing class Bolt { + public final static String STARTS_WITH_ARRAY_TOKEN = '$ARRAY$'; @AuraEnabled(cacheable=true) - public static Object[] soqlQuery(string query, String params, string mode) { + public static Object[] soqlQuery(String query, String params, String mode) { AccessLevel level = mode == 'WITH USER_MODE' ? AccessLevel.USER_MODE : AccessLevel.SYSTEM_MODE; Map bindParams = (Map) JSON.deserializeUntyped(params); + // Map bindArrayArgs = (Map) JSON.deserializeUntyped(arrayArgs); + Map currentArrayArg = new Map(); + for(String key : bindParams.keySet()){ + String maybeArrayPayload = String.valueOf(bindParams.get(key)); + if(maybeArrayPayload.startsWith(STARTS_WITH_ARRAY_TOKEN)){ + currentArrayArg = (Map) JSON.deserializeUntyped( + maybeArrayPayload.replace(STARTS_WITH_ARRAY_TOKEN, '') + ); + bindParams.put(key, currentArrayArg.keySet()); + } + } return Database.queryWithBinds( - query, + query, bindParams, level ); } -} \ No newline at end of file +}