From wiki.ginstr.com
Revision as of 21:24, 12 July 2017 by Mark (talk | contribs) (formatting)
Jump to: navigation, search

queries.xml

queries.xml is an XML file located in app/database/ folder.
This file contains all queries which are used to read any data from the database.
It is necessary to create a "layout" for that data which is identical to the persistent storage structure. These "layouts" are called views. Once a view is created data is copied based on query from the database view into the persistent storage structure.

XML Attributes Description

Attribute Description
id represents a view name
columns represents a list of column names which belong to the same table and will be a part of query result
keys represents a list of view keys (column names) which belong to the same table and will be used to query the data
type represents a list of query types

More information here

Example

<?xml version="1.0" encoding="utf-8"?>
<queries>
  <query 
    id="employeesByRecordId" 
    columns="
      employee_firstName,
      employee_lastName"
    keys="_id" />

  <query id="employeesByNFCTag" 
    columns="
      employee_firstName,
      employee_lastName"
    keys="employee_NFCtag" />

  <query id="devicesOverviewByNameAndFacilitySortByName" 
    columns="
      device_name,
      device_sequenceNo,
      device_buildingZone,
      device_floor,
      device_location,
      device_NFCtag"
    keys="device_facility,device_name" />

  <query 
    id="driversByFirstAndLastName" 
    columns="
      Driver_firstName,
      Driver_lastName,
      Driver_firstAndLastName,
      Driver_comments,
      Driver_subName"
    type="INDEX"
    keys="Driver_firstName,Driver_lastName" />
</queries>

View types

View type Description
AND returns documents for key group (default value)
OR returns documents for each key in key group
INDEX returns list of document ids for key group