Skip to content

Instantly share code, notes, and snippets.

@nithesh1992
Last active March 19, 2019 19:52
Show Gist options
  • Save nithesh1992/9b33ab34380f29d81c35236382947686 to your computer and use it in GitHub Desktop.
Save nithesh1992/9b33ab34380f29d81c35236382947686 to your computer and use it in GitHub Desktop.

Service Components

DML

Aura Methods: [ bulkInsert, bulkUpdate, bulkDelete ]

// In cmp
      <c:DML sObjectType="Contact" aura:id="dmlUtil" />    

// In Controller/Helper js
      cmp.find("dmlUtil").bulkInsert(recs, (result) => {
           // result.error -> String
           // result.records -> array of objects
      });

Feature Setting

    <aura:attribute name="inActive" type="Boolean" default="false" />

    <c:FeatureSetting Name="Feature Name" inActive = "{!v.inActive}" />

    <aura:if isTrue="{!!v.inActive}">
         <!-- Feature Code -->
    </aura:if>

Logger

// In cmp
    <c:Logger aura:id="logger" />

// In Controller/Helper js
    cmp.find("logger").log({"Status" : "Query Successful"}, "success", <optional external logging - true by default>);

Soql

For Simple Queries only.

// In cmp
    <c:SoqlUtil aura:id="soql" />

// In Controller/Helper js
    cmp.find("soql").query(
       "SELECT Id, FirstName, LastName FROM Contact Where CreatedDate = TODAY",
            function(result){
                console.log(result);
            }
    );

Code Snippet [For Hands-On]

<aura:component extends="c:SheildDashBoard" implements="flexipage:availableForAllPageTypes" access="global">
    <div class="slds-m-around_large">
        <span class="slds-badge">Total : {!v.total} </span> <br/> <br/>
        <span class="slds-badge">Combat Unit : {!v.combat} </span> <br/> <br/>
        <span class="slds-badge">Black-Ops : {!v.blackOps} </span>
    </div>
</aura:component>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment