Fetch a list of output columns and their attributes that are avaialble from a given query
labkey.getQueryDetails(baseUrl, folderPath, schemaName, queryName)
The available schemas are returned as a data frame:
the name of the query, repeated n times, where n is the number of output fields from the query
the fully qualified name of the field, relative to the specified queryName.
a more readable label for the data field, appears as a column header in grids
the name part that identifies this field within its containing table, independent of its use as a lookup target.
a string specifying the field type, e.g. Text, Number, Date, Integer
TRUE if the field can be left empty (null)
TRUE if the field is part of the primary key
TRUE if the system will automatically assign a sequential integer in this on inserting a record
TRUE if the field issued to detect changes since last read
TRUE if the field is not displayed by default
reserved for future use.
reserved for future use.
reserved for future use
reserved for future use
for a field defined as a lookup the primary key column of the query referenced by the lookup field; NA for non-lookup fields
the schema of the query referenced by the lookup field; NA for non-lookup fields
the field from the query referenced by the lookup field that is shown by default in place of the lookup field; NA for non-lookup fields
the query referenced by the lookup field; NA for non-lookup fields. A non-NA value indicates that you can use this field in a call to getLookups
reserved for future use
a string specifying the address of the LabKey Server, including the context root
a string specifying the hierarchy of folders to the current folder (container) for the operation, starting with the project folder
a string specifying the schema name in which the query object is defined
a string specifying the name of the query
Peter Hussey, peter@labkey.com
Queries have a default output list of fields defined by the "default view" of the query.
To retrieve that set of fields with their detailed properties such as type and nullability, use
labkey.getQueryDetails
function. Function arguments are the components of the url that identify
the location of the server, the folder path, the schema, and the name of the query.
The results from getQueryDetails describe the “field names” that are used to build the colSelect,
colFilter and colSort parameters to selectRows. Each column in the data frame returned from selectRows
corresponds to a field in the colSelect list.
There are two types of fieldNames that will be reported by the server in the output of this function. For fields that are
directly defined in the query corresponding the queryName parameter for this function, the fieldName
is simply the name assigned by the query. Because selectRows returns the results specified by the default view, however,
there may be cases where this default view incorporates data from other queries that have a defined 1-M relationship
with the table designated by the queryName. Such fields in related tables are referred to as “lookup” fields.
Lookup fields have multi-part names using a forward slash as the delimiter. For example, in a samples data set, if the ParticipantId
identifies the source of the sample, ParticipantId/CohortId/CohortName
could be a reference to a CohortName
field
in a Cohorts
data set.
These lookup fieldNames can appear in the default view and show up in the selectRows result. If a field from a lookup table
is not in the default view, it can still be added to the output column list of labkey.selectRows
. Use the
labkey.getLookups to discover what additional fields are available via lookups, and then put their multipart fieldName values
into the colSelect list. Lookup fields have the semantics of a LEFT JOIN in SQL, such that
every record from the target queryName appears in the output whether or not there is a matching lookup field value.
labkey.selectRows
,
makeFilter
,
labkey.executeSql
,
labkey.updateRows
,
labkey.insertRows
,
labkey.importRows
,
labkey.deleteRows
,
labkey.getSchemas
,
labkey.getQueries
,
labkey.getQueryViews
,
labkey.getDefaultViewDetails
,
labkey.getLookupDetails
if (FALSE) {
## Details of fields of a query
# library(Rlabkey)
queryDF<-labkey.getQueryDetails(
baseUrl="http://localhost:8080/labkey",
folderPath="/apisamples",
schemaName="lists",
queryName="AllTypes")
}
Run the code above in your browser using DataLab