Close Menu Login2XplorE Home Docs Contact
J PDB   

JPDB Examples


Getting Started.

  • Prerequisite : Basic understanding of HTML, JavaScript and JSON.
  • Open a developer account by clicking on the link Developer API.
  • You will receive an email with credentials to login into developer dashboard. This credential will be used to connect to JPDB database in your program code.


Using JPDB for HTML Form data - Easiest Way

# How to get the 'connection-token' to connect to JsonPowerDB in your program / code :

  • Login to JPDB API Dashboard .
  • Dashboard -> Tools -> Tokens .
  • Select 'connection-token' option from dropdown.
  • Select and Copy existing connection token (create a new connection token if there is no token) .

# JsonPowerDB - Easiest Way to store and retrieve HTML Form Data

  1. Copy and Paste following HTML form in your IDE / Editor / Notepad etc. Save this in file register.html .
    (This form will not work till you have serverside programming to receive data and process data).
    
    
                                                

  2. Following changes will make this form working, without any serverside programming.
    (Remember : JsonPowerDB has support for Serverless programming to make your code much smaller, easier and faster)
    • Add the following code in '<head>' section:
       
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src="http://login2explore.com/jpdb/resources/js/jpdb-commons.js"></script>
      
                                                          
    • Replace the existing '<form>' tag with the following:
      (Paste your connection token in the value of data-connection-token in this form tag.
      To know more about the syntax of '<form>' tag click here)
      
      <form id="RegisterForm" method="post"
      data-connection-token="your-connection-token"
      data-db-name="MyDatabase" 
      data-table-name="MyUsers"
      data-success-msg="Thanks for Registering"
      data-error-msg="Data NOT submited."
      onsubmit="return insertFormData2JPDB(this.id);">
      
                                                      
    • Open this page in your browser and fill the form and submit, That's it.

  3. Now to see your data goto: Visualize -> JPDB
    • Select 'MyDatabase' database
    • Select 'MyUsers' Relation

Wow!! Congrats!

Your first HTML form is Working without any Serverside programming
Even without Any Sever setup or installation or configuration or deployment
Surprised!! . . . YESsss JsonPowerDB is simplest, fastest serverless database to develop Dynamic Web, Desktop and Mobile applications - Hurray!.


Download Themes Energized by JsonPowerDB

This themes are taken from W3Schools.com


Exploring CRUD

# Create - This session is to practice on how to add HTML form data into database.

  1. You can just start with any of your favorite IDE with a new 'HTML and Javascript' web project.
    or
    Create a new file using notepad / edit / gedit or any of the text editor of your choice.
  2. Copy the following code by clicking on button at the top right of the code block and Paste it in the newly created file.
  3. Find the code var connToken = "connection-token";, modify this with your 'connection-token' taken from JPDB dashboard and save it with any file-name and extenstion '.html'.
  4. Open this file in browser to see the code working. Add few records.
  5. Confirm adding of data by logging into the Developer API Dashboard than click on Visualize option on left navigation.

                                    

Most of the code in the above example is self explanatory. The important points are:

Use of 'jpdb-commons.js' Javascript library to speedup the development.

                                             
                                                <script src="http://login2explore.com/jpdb/resources/js/jpdb-commons.js"></script>
                                            
                                        

Below code snippet defines the JPDB API end point used for manipulating the data i.e. Index Manipulation Language (iml).

                                             
                                                var apiBaseUrl = "http://api.login2explore.com:5577";    // API Base URL
                                                var imlPartUrl = "/api/iml";                           // API End-Point Part URL
                                            
                                        

Variables to be defined with your choice of database name and relation name.

                                             
                                                // TBD Change the dbName and relName with your choice of database name and relation name.
                                                var dbName = "company_db";
                                                var relName = "emp_rel";
                                            
                                        

Following Javascript methods are created to make this example page working.

                                             
                                                
                                                //To Set api base Url so that user can locate its data to baseUrl of another JPDB instance
                                                function setBaseUrl(apiBaseUrl);
                                                
                                                // Send data to JPDB instance for inserting in the give relation for the user database.
                                                function mySave() {... } 
                                           
                                                // Initializes form data to default values 
                                                function resetFormData() {... }
                                           
                                                // Restore form field focus to first field.
                                                function resetFocus() {... }
                                            
                                        

This line will set the apiBaseUrl to the Url which you wants to set.

                                             
                                                setBaseUrl(apiBaseUrl);
                                            
                                        

This line will read the form data and convert it to Json object.

                                             
                                                var formDataInJson = getFormDataInJson($form);
                                            
                                        

Connection token is required to call the JPDB API. Replace 'connection-token' with your connection-token taken from JPDB dashboard.

                                             
                                                var connToken = "connection-token";
                                            
                                        

Creates a PUT json request.

                                             
                                                var putReq = createPUTRequest(connToken, jsonObj, dbName, relName);
                                            
                                        

Ajax (POST) call to JPDB API with the given json request.

                                             
                                                var respJson = executeCommand(putReq, imlPartUrl);
                                            
                                        

# Retrieve - This session is to practice on how to retrieve data from database.

  1. Create a new HTML file and copy the following code.
  2. You must change the 'connection-token' for getting connection to JPDB.

                                    

Most of the code in the above example is self explanatory. The important points are:

Following Javascript methods are created to make this example page working.

                                             
                                                // Retrieve an employee record based on Employee ID.
                                                function getEmployee() {... } 
                                           
                                                // Get next record details from JsonPowerDB database
                                                function getNextRecord() {... }
                                                
                                                // Get previous record details from JsonPowerDB database
                                                function getPrevRecord() {... }
                                                
                                                // Get first record details from JsonPowerDB database
                                                function getFirstRecord() {... }
                                                
                                                // Get last record details from JsonPowerDB database
                                                function getLastRecord() {... }
                                           
                                                // Set and display data in the form 
                                                function setDataInFormFields(respRecordJson) {... }
                                            
                                        

Creates a FIND_RECORD json request.

                                             
                                                var getFindRecordReq = createFIND_RECORDRequest(connToken, dbName, relName, jsonObj);
                                            
                                        

Creates a NEXT_RECORD json request.

                                             
                                                var getNextRecordReq = createNEXT_RECORDRequest(connToken, dbName, relName, recordNumber);
                                            
                                        

Creates a PREV_RECORD json request.

                                             
                                                var getPreviousRecordReq = createPREV_RECORDRequest(connToken, dbName, relName, recordNumber);
                                            
                                        

Creates a FIRST_RECORD json request.

                                             
                                                var getFirstRecordReq = createFIRST_RECORDRequest(connToken, dbName, relName);
                                            
                                        

Creates a LAST_RECORD json request.

                                             
                                                var getLastRecordReq = createLAST_RECORDRequest(connToken, dbName, relName);
                                            
                                        
  1. Create a new HTML file and copy the following code by clicking on button at the top right of the code block and Paste it in the newly created file.
  2. Find the code var connToken = "connection-token"; and modify this with your connection-token taken from JPDB dashboard.

                                    

Most of the code in the above example is self explanatory. The important points are:

Following Javascript methods are created to make this example page working.

                                             
                                                // Set a page when a particular button is clicked.
                                                function setPage(buttonId) {... } 
                                           
                                                // Managing enable or disable buttons as per displayed page 
                                                function buttonDisabled() {... }
                                           
                                                // Get all data from JPDB database according to the page number and page size.
                                                function getPage(pageNo, pageSize){... }
                                           
                                                // Create table heading
                                                function createTableHeader(dataColumn){... }
                                           
                                                // Create table rows and table data columns according to the requested page number and page size.
                                                function createTableRows(jsonArrayData, dataColumn){... }
                                            
                                        

Creates a GETALLCOL json request.

                                             
                                                var getReqCol = createGETALLCOLRequest(connToken, dbName, relName);
                                            
                                        

Creates a GETALL json request.

                                             
                                                var getReqData = createGETALLRequest(connToken, dbName, relName, pageNo, pageSize);
                                            
                                        

# Delete - This session is to practice on how to delete data from JsonPowerDB.

  1. Create a new HTML file and copy the following code.
  2. You must change the connection-token for getting connection to JPDB.

                                    

Most of the code in the above example is self explanatory. The important points are:

Following Javascript method created to make this example page working.

                                             
                                                // Delete a particular record when delete button is clicked.
                                                function deleteRecord(reqId) {... } 
                                            
                                        

Creates a REMOVE json request.

                                            
                                                var getRemoveRequest = createREMOVERecordRequest(connToken, dbName, relName, reqId);
                                            
                                        

# Update - This session is to practice on how to update data in JsonPowerDB.

The following code is having an edit button which will redirect you to ' Edit Employee ' page and remaining code is same as ' Retrieve Multiple Record with Delete Operation '.


                                    

Create a another HTML file and copy the following code to edit / update the employee details.


                                    

Following Javascript methods are created in Edit Employee Page.

                                             
                                                // Get Record Number from URL.
                                                function getRecordNumber() {... } 
                                                
                                                // Get record details of a particular record number.
                                                function getRecordDetails() {... } 
                                                
                                                // Get the record details from local storage in case of cancel update.
                                                function getDataOnCancelEvent() {... } 
                                                
                                                // Update a particular record details in the JPDB database.
                                                function updateRecord() {... } 
                                                
                                                // Get the form data and check whether any changes occur or not.
                                                function getChangedFormDataInJson($form) {... }
                                            
                                        

Creates a GET_RECORD json request.

                                            
                                                var getReqRecord = createGET_RECORDRequest(connToken, dbName, relName, recordNumber);
                                            
                                        

Creates a UPDATE json request.

                                            
                                                var getReqUpadateRecord = createUPDATERecordRequest(connToken, formJsonStr, dbName, relName, recordNumber);
                                            
                                        

# Create - Advance - Example code to manage unique key while inserting new data

  1. Create a new HTML file and copy the following code.
  2. You must change the connetion-token for getting connection to JPDB.

                                    

Most of the code in the above example is self explanatory. The important points are:

Following Javascript methods are created to make this example page working.

                                             
                                                // Check whether a particular record is exist or not in JSONPowerDB database.
                                                 function checkExistingData() {... } 
                                            
                                        

Creates a FIND_RECORD json request.

                                            
                                                var getReqData = createFIND_RECORDRequest(connToken, dbName, relName, dataObj);
                                            
                                        

NoSQL Examples


Using following schema and data


Department (dpt_id(String), dpt_name(String), dpt_manager_emp_idl(long))
Employee (emp_id(String), emp_name(String), emp_sex((String)), emp_dsg(String), emp_basic(long), emp_allowance(double), emp_ded(double), emp_net(double), emp_lead_id(String), emp_dpt_id(String))
Projects (prj_id(String), prj_name(String), prj_start_date(String), is_prj_active(String), prj_rmk(String), prj_mgr_emp_id(String) )
ProjectEmployee (prj_id(String), emp_id(String), emp_hrs(long))

                                            

{"dpt_id":"00H", "dpt_name":"HR", "dpt_manager_emp_idl":109},
{"dpt_id":"00J", "dpt_name":"JAVA", "dpt_manager_emp_idl":101},
{"dpt_id":"00P", "dpt_name":"PHP", "dpt_manager_emp_idl":101},
{"dpt_id":"00U", "dpt_name":"UI", "dpt_manager_emp_idl":101},
{"dpt_id":"00A", "dpt_name":"ACCOUNTS", "dpt_manager_emp_idl":115},
{"dpt_id":"00OP", "dpt_name":"OPERATIONS", "dpt_manager_emp_idl":105},
{"dpt_id":"00Q", "dpt_name":"QA", "dpt_manager_emp_idl":101}

                                            
  • Every department has exactly one manager.
  • More than one department can have same manager.


{"emp_id":"119", "emp_name":"MONALI LALWANI", "emp_sex":"M", "emp_dsg":"php developer", "emp_basic":15000, "emp_allowance":1500.0, "emp_ded":0.0, "emp_net":0.0, "emp_lead_id":"102", "emp_dpt_id":"00P"}, 
{"emp_id":"120", "emp_name":"SOURBH SHARMA", "emp_sex":"M", "emp_dsg":"java developer", "emp_basic":20000, "emp_allowance":2000.0, "emp_ded":0.0, "emp_net":0.0, "emp_lead_id":"106", "emp_dpt_id":"00J"}, 
{"emp_id":"101", "emp_name":"ARPIT TODEWALE", "emp_sex":"M", "emp_dsg":"Technical head java", "emp_basic":25000, "emp_allowance":2500.0, "emp_ded":0.0, "emp_net":0.0, "emp_lead_id":"105", "emp_dpt_id":"00J"},
{"emp_id":"102", "emp_name":"SANJAY VERMA", "emp_sex":"M", "emp_dsg":"php developer lead", "emp_basic":25000, "emp_allowance":2500.0, "emp_ded":0.0, "emp_net":0.0, "emp_lead_id":"101", "emp_dpt_id":"00P"},
{"emp_id":"103", "emp_name":"SALONI PATNI", "emp_sex":"F", "emp_dsg":"QA lead", "emp_basic":20000, "emp_allowance":2000.0, "emp_ded":0.0, "emp_net":0.0, "emp_lead_id":"101", "emp_dpt_id":"00Q"}, 
{"emp_id":"104", "emp_name":"DEEPAK PAL", "emp_sex":"M", "emp_dsg":"UI developer", "emp_basic":15000, "emp_allowance":1500.0, "emp_ded":0.0, "emp_net":0.0, "emp_lead_id":"112", "emp_dpt_id":"00U"},
{"emp_id":"105", "emp_name":"ARPIT SHARMA", "emp_sex":"M", "emp_dsg":"CEO", "emp_basic":40000, "emp_allowance":4000.0, "emp_ded":0.0, "emp_net":0.0, "emp_lead_id":"", "emp_dpt_id":"00OP"}, 
{"emp_id":"106", "emp_name":"RAHUL GUPTA", "emp_sex":"M", "emp_dsg":"java developer lead", "emp_basic":25000, "emp_allowance":2500.0, "emp_ded":0.0, "emp_net":0.0, "emp_lead_id":"101", "emp_dpt_id":"00J"},
{"emp_id":"107", "emp_name":"ADITI PHADNIS", "emp_sex":"F", "emp_dsg":"HR", "emp_basic":20000, "emp_allowance":2000.0, "emp_ded":0.0, "emp_net":0.0, "emp_lead_id":"109", "emp_dpt_id":"00H"}, 
{"emp_id":"108", "emp_name":"SURABHI ARYA", "emp_sex":"F", "emp_dsg":"java developer", "emp_basic":20000, "emp_allowance":2000.0, "emp_ded":0.0, "emp_net":0.0, "emp_lead_id":"106", "emp_dpt_id":"00J"}, 
{"emp_id":"109", "emp_name":"ABHISHEK TRIPATHI", "emp_sex":"M", "emp_dsg":"HR manager", "emp_basic":25000, "emp_allowance":2500.0, "emp_ded":0.0, "emp_net":0.0, "emp_lead_id":"105", "emp_dpt_id":"00H"}, 
{"emp_id":"110", "emp_name":"MUKUND JHA", "emp_sex":"M", "emp_dsg":"Operator", "emp_basic":15000, "emp_allowance":1500.0, "emp_ded":0.0, "emp_net":0.0, "emp_lead_id":"105", "emp_dpt_id":"00OP"},
{"emp_id":"111", "emp_name":"PRITHVIRAJ PRAMANIK", "emp_sex":"M", "emp_dsg":"java developer", "emp_basic":20000, "emp_allowance":2000.0, "emp_ded":0.0, "emp_net":0.0, "emp_lead_id":"106", "emp_dpt_id":"00J"},
{"emp_id":"112", "emp_name":"ANISHA TULIKA", "emp_sex":"F", "emp_dsg":"UI designer", "emp_basic":15000, "emp_allowance":1500.0, "emp_ded":0.0, "emp_net":0.0, "emp_lead_id":"101", "emp_dpt_id":"00U"}, 
{"emp_id":"113", "emp_name":"AKSHITA SINGH", "emp_sex":"F", "emp_dsg":"php developer", "emp_basic":20000, "emp_allowance":2000.0, "emp_ded":0.0, "emp_net":0.0, "emp_lead_id":"102", "emp_dpt_id":"00P"}, 
{"emp_id":"114", "emp_name":"BHAWNA ARORA", "emp_sex":"F", "emp_dsg":"QA", "emp_basic":15000, "emp_allowance":1500.0, "emp_ded":0.0, "emp_net":0.0, "emp_lead_id":"103", "emp_dpt_id":"00Q"}, 
{"emp_id":"115", "emp_name":"SHRADDHA SHARMA", "emp_sex":"F", "emp_dsg":"Accountant manager", "emp_basic":25000, "emp_allowance":2500.0, "emp_ded":0.0, "emp_net":0.0, "emp_lead_id":"105", "emp_dpt_id":"00A"},
{"emp_id":"116", "emp_name":"RAJEEV JOSHI", "emp_sex":"M", "emp_dsg":"java developer", "emp_basic":20000, "emp_allowance":2000.0, "emp_ded":0.0, "emp_net":0.0, "emp_lead_id":"106", "emp_dpt_id":"00J"}, 
{"emp_id":"117", "emp_name":"SNEHASHISH DAS", "emp_sex":"M", "emp_dsg":"junior php dev", "emp_basic":10000, "emp_allowance":1000.0, "emp_ded":0.0, "emp_net":0.0, "emp_lead_id":"102", "emp_dpt_id":"00P"} 

                                            
  • Every employee has one manager / lead.
  • CEO do not have any manager / lead.
  • Every employee works for exactly 1 department.

{"prj_id":"1L", "prj_name":"Library management system", "prj_start_date":"01/01/2018", "is_prj_active":"true", "prj_rmk":"Project on schedule", "prj_mgr_emp_id":"106"},
{"prj_id":"2HT", "prj_name":"Hotel management system", "prj_start_date":"08/11/2017", "is_prj_active":"true", "prj_rmk":"Project under testing", "prj_mgr_emp_id":"102"},
{"prj_id":"3HP", "prj_name":"Hospital management system", "prj_start_date":"27/06/2017", "is_prj_active":"true", "prj_rmk":"Project behind schedule", "prj_mgr_emp_id":"106"},
{"prj_id":"4B", "prj_name":"Banking management system", "prj_start_date":"09/08/2017", "is_prj_active":"true", "prj_rmk":"Project on schedule", "prj_mgr_emp_id":"102"},
{"prj_id":"5I", "prj_name":"Inventory management system", "prj_start_date":"15/06/2016", "is_prj_active":"false", "prj_rmk":"Project completed", "prj_mgr_emp_id":"106"} 
  

                                            
  • Every project has exactly 1 project manager.

{"prj_id":"1L", "emp_id":"106", "emp_hrs":7}, 
{"prj_id":"1L", "emp_id":"102", "emp_hrs":8}, 
{"prj_id":"1L", "emp_id":"120", "emp_hrs":8}, 
{"prj_id":"1L", "emp_id":"119", "emp_hrs":7}, 
{"prj_id":"2HT", "emp_id":"106", "emp_hrs":5}, 
{"prj_id":"2HT", "emp_id":"108", "emp_hrs":7}, 
{"prj_id":"2HT", "emp_id":"102", "emp_hrs":8}, 
{"prj_id":"2HT", "emp_id":"113", "emp_hrs":7}, 
{"prj_id":"3HP", "emp_id":"111", "emp_hrs":8}, 
{"prj_id":"3HP", "emp_id":"106", "emp_hrs":7}, 
{"prj_id":"3HP", "emp_id":"102", "emp_hrs":8}, 
{"prj_id":"4B", "emp_id":"106", "emp_hrs":5}, 
{"prj_id":"4B", "emp_id":"116", "emp_hrs":5}, 
{"prj_id":"4B", "emp_id":"117", "emp_hrs":7}, 
{"prj_id":"4B", "emp_id":"118", "emp_hrs":8}, 
{"prj_id":"4B", "emp_id":"102", "emp_hrs":8}, 
{"prj_id":"5I", "emp_id":"106", "emp_hrs":5}, 
{"prj_id":"5I", "emp_id":"102", "emp_hrs":7}

                                            
  • One or more employee can work in same project.
  • One employee can work in more than one project.

# Insert sample data

  • Using Dashboard : Login to dashboard, copy the sample data from 'Company' Database Schema and insert the data by using Insert Multiple Record of Execute menu.

# How to create NoSQL scripts (only in Dashboard) : Open user dashboard and click on the NoSQL and follow the following:

  • Script : Insert script name as your NoSQL script is identified by this name and write your NoSql query code into the provided editor and then compile it. Copy any JPDB NoSQL script shown in next section and paste it in this window.
  • Parameters : If your NoSQL query needed any parameters then by clicking on ' Add Parameter ' button you can add parameters as you need.
  • Console : It shows console output, compile time and run time errors.
  • GetJsonCode : After successful compilation of the code, your current NoSQL script json request is displayed which shows NoSQL script name and parameters.

# How to execute NoSQL query and see results using Dashboard :

  • Save and Run : After successful compilation of the code, your NoSQL script json request is displayed, then you can save and execute your NoSQL query by clicking on 'Save and Run' button.
  • Result : The Result of your NoSQL script is shown here.

# Executing NoSQL Query from Program

Http method : POST
Base url : http://api.login2explore.com:5577
End-point url : /api/isl

SELECT PRJ_NAME FROM PROJECTS WHERE IS_PRJ_ACTIVE = 'TRUE';

Object projectActive = params.get("isActive");
ArrayList <Integer> proActiveArr = QueryService.get("Company","Projects","is_prj_active",projectActive,this);
finalQueryResult = QueryService.project("Company","Projects",proActiveArr, new String[]{"prj_name"},this);

                                            

{
"token": "-1167378244|1086969151789951602|-1167386760",
"cmd": "EXECUTE_SCRIPT",
"jsonStr": {
	"scriptName": "display_active_project_name",
	"scriptParams":{"isActive":"true"}
	}
}

                                            
SELECT EMP_NAME FROM EMPLOYEE WHERE EMP_LEAD_ID ='105';

Object empLead = params.get("leadId");
ArrayList <Integer> empDetails = QueryService.get("Company","Employee","emp_lead_id",empLead,this);
finalQueryResult = QueryService.project("Company","Employee",empDetails,new String[]{"emp_name"},this);

                                            

{
"token": "-1167378244|1086969151789951602|-1167386760",
"cmd": "EXECUTE_SCRIPT",
"jsonStr": {
	"scriptName": "emp_name_answer_to_lead",
	"scriptParams":{"leadId":"105"}
	}
}

                                            
SELECT EMP_NAME, EMP_DSG,EMP_BASIC FROM EMPLOYEE WHERE EMP_DPT_ID = '00OP';

Object deptId = params.get("opDeptId");
ArrayList <Integer> empOopDeptDetails = QueryService.get("Company","Employee","emp_dpt_id",deptId,this);
finalQueryResult = QueryService.project("Company","Employee",empOopDeptDetails,new String[]{"emp_name","emp_dsg","emp_basic"},this);

                                            

{
"token": "-1167378244|1086969151789951602|-1167386760",
"cmd": "EXECUTE_SCRIPT",
"jsonStr": {
	"scriptName": "operation_dept_emp_details",
	"scriptParams":{"opDeptId":"00OP"}
	}
}

                                            
SELECT EMP_NAME FROM EMPLOYEE WHERE EMP_SEX='M' AND EMP_DPT_ID='00J';

Object empGender = params.get("empGender");
Object empDpt = params.get("empDepartment");
ArrayList <Integer> empGenderArr = QueryService.get("Company", "Employee", "emp_sex", empGender,this);


ArrayList <Integer> empDptArr = QueryService.get("Company","Employee","emp_dpt_id",empDpt,this);


ArrayList<Integer> finalEmpNametList = SetOpUtils.intersection(empGenderArr, empDptArr);
finalQueryResult = QueryService.project("Company", "Employee", finalEmpNametList, new String[]{"emp_dpt_id","emp_name"}, this);

                                            

{
"token": "-1167378244|1086969151789951602|-1167386760",
"cmd": "EXECUTE_SCRIPT",
"jsonStr": {
	"scriptName": "name_java_male_employee",
	"scriptParams":{"empGender":"M","empDepartment":"00J"}
	}
}

                                            
SELECT EMP_NAME FROM EMPLOYEE WHERE EMP_DPT_ID IN ('00OP','00A');

Object empDpt1 = params.get("dpt1");
Object empDpt2 = params.get("dpt2");
ArrayList <Integer> empDpt1Details = QueryService.get("Company","Employee","emp_dpt_id",empDpt1,this);


ArrayList <Integer> empDpt2Details = QueryService.get("Company","Employee","emp_dpt_id",empDpt2,this);


ArrayList <Integer> finalEmpNametList = SetOpUtils.union(empDpt1Details, empDpt2Details);
finalQueryResult = QueryService.project("Company", "Employee", finalEmpNametList, new String[]{"emp_dpt_id","emp_name"}, this);

                                            

{
"token": "-1167378244|1086969151789951602|-1167386760",
"cmd": "EXECUTE_SCRIPT",
"jsonStr": {
	"scriptName": "all_emp_name_in_account_operation_dept",
	"scriptParams":{"dpt2":"00OP","dpt1":"00A"}
	}
}

                                            
SELECT DPT_NAME , EMP_NAME AS "MANAGER NAME" FROM DEPARTMENT D, EMPLOYEE E WHERE D.DPT_MANAGER_EMP_ID = E.EMP_ID;

int totalRec = QueryService.getFileSize("Company","Department",this);
ArrayList <Integer> idList = QueryService.getAll("Company","Department","dpt_id","","zzz",totalRec, this);


for(int i=0; i< idList.size();i++){
    JSONObject finalRowJSONObj = new JSONObject();
    Record rec = QueryService.get("Company","Department",idList.get(i),this);
    JSONObject empJsonObj = rec.getJsonObject();
    finalRowJSONObj.put("managerId", empJsonObj.get("dpt_manager_emp_idl"));
    finalRowJSONObj.put("deptName", empJsonObj.get ("dpt_name"));
    String managerEmpId = (String)empJsonObj.get("dpt_manager_emp_idl").toString();
    ArrayList <Integer> empDetailsList = QueryService.get("Company","Employee","emp_id",managerEmpId,this);
    Record empRecDetails = QueryService.get("Company","Employee", empDetailsList.get(0),this);
    JSONObject empRecJsonObj = empRecDetails.getJsonObject();
    finalRowJSONObj.put("managerName ", empRecJsonObj.get("emp_name"));
    finalQueryResult.addRecord(new Record(new Row(i,finalRowJSONObj)));
}

                                            

{
"token": "-1167378247|1086969151769521885|-1167389995",
"cmd": "EXECUTE_SCRIPT",
"jsonStr": {
	"scriptName": "manager_name_with_dept_name",
	"scriptParams":
	}
}                                        

                                            

KvpDB Examples


Under construction!

Tutorials


Under construction!