Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Query

Index

Variables

Const URL_COLUMN_PREFIX

URL_COLUMN_PREFIX: "_labkeyurl_" = "_labkeyurl_"

Const containerFilter

containerFilter: typeof ContainerFilter = ContainerFilter
deprecated

Backwards compatible reference to ContainerFilter.

Const experimental

experimental: { SQL: typeof import("/Users/nickkerr/code/labkey/labkey-api-js/src/labkey/query/experimental/SQL") } = {SQL}

Type declaration

  • SQL: typeof import("/Users/nickkerr/code/labkey/labkey-api-js/src/labkey/query/experimental/SQL")

Functions

buildQueryParams

  • buildQueryParams(schemaName: string, queryName: string, filterArray: IFilter[], sort: string, dataRegionName?: string): any
  • Build and return an object suitable for passing to the Ajax request 'params' configuration property.

    Parameters

    • schemaName: string
    • queryName: string
    • filterArray: IFilter[]
    • sort: string
    • Optional dataRegionName: string

    Returns any

deleteQueryView

  • deleteQueryView(options: DeleteQueryViewOptions): XMLHttpRequest
  • Parameters

    • options: DeleteQueryViewOptions

    Returns XMLHttpRequest

deleteRows

  • deleteRows(options: QueryRequestOptions): XMLHttpRequest
  • Delete specific rows in a table.

    Parameters

    • options: QueryRequestOptions

    Returns XMLHttpRequest

    In client-side scripts, this method will return a transaction id for the async request that can be used to cancel the request. In server-side scripts, this method will return the JSON response object (first parameter of the success or failure callbacks).

executeSql

  • executeSql(options: IExecuteSqlOptions): XMLHttpRequest
  • Execute arbitrary LabKey SQL. For more information, see the LabKey SQL Reference.

    Examples

    Example, from the Reagent Request Confirmation Tutorial and Demo:

    // This snippet extracts a table of UserID, TotalRequests and
    // TotalQuantity from the "Reagent Requests" list.
    // Upon success, the writeTotals function (not included here) uses the
    // returned data object to display total requests and total quantities.
    
    LABKEY.Query.executeSql({
            containerPath: 'home/Study/demo/guestaccess',
            schemaName: 'lists',
            sql: 'SELECT "Reagent Requests".UserID AS UserID, \
                Count("Reagent Requests".UserID) AS TotalRequests, \
                Sum("Reagent Requests".Quantity) AS TotalQuantity \
                FROM "Reagent Requests" Group BY "Reagent Requests".UserID',
            success: writeTotals
    });
    

    Parameters

    • options: IExecuteSqlOptions

    Returns XMLHttpRequest

    In client-side scripts, this method will return a transaction id for the async request that can be used to cancel the request. In server-side scripts, this method will return the JSON response object (first parameter of the success or failure callbacks).

getDataViews

  • getDataViews(options: IGetDataViewsOptions): XMLHttpRequest
  • Returns a list of reports, views and/or datasets in a container

    Parameters

    • options: IGetDataViewsOptions

    Returns XMLHttpRequest

getQueries

  • getQueries(options: GetQueriesOptions): XMLHttpRequest
  • Returns the set of queries available in a given schema.

    Parameters

    • options: GetQueriesOptions

    Returns XMLHttpRequest

getQueryDetails

  • getQueryDetails(options: GetQueryDetailsOptions): XMLHttpRequest
  • Returns details about a given query including detailed information about result columns.

    Parameters

    • options: GetQueryDetailsOptions

    Returns XMLHttpRequest

    In client-side scripts, this method will return a transaction id for the async request that can be used to cancel the request. In server-side scripts, this method will return the JSON response object (first parameter of the success or failure callbacks).

getQueryViews

  • getQueryViews(options: GetQueryViewsOptions): XMLHttpRequest
  • Returns the set of views available for a given query in a given schema.

    Parameters

    • options: GetQueryViewsOptions

    Returns XMLHttpRequest

getSchemas

  • getSchemas(options: GetSchemasOptions): XMLHttpRequest
  • Returns the set of schemas available in the specified container.

    Parameters

    • options: GetSchemasOptions

    Returns XMLHttpRequest

getServerDate

  • Returns the current date/time on the LabKey server.

    Parameters

    Returns XMLHttpRequest

    In client-side scripts, this method will return a transaction id for the async request that can be used to cancel the request. In server-side scripts, this method will return the JSON response object (first parameter of the success or failure callbacks).

insertRows

  • insertRows(options: QueryRequestOptions): XMLHttpRequest
  • Insert rows.

    Examples

    // This snippet inserts data from the ReagentReqForm into a list.
    // Upon success, it moves the user to the confirmation page and
    // passes the current user's ID to that page.
    LABKEY.Query.insertRows({
        containerPath: '/home/Study/demo/guestaccess',
        schemaName: 'lists',
        queryName: 'Reagent Requests',
        rows: [{
           "Name":  ReagentReqForm.DisplayName.value,
           "Email": ReagentReqForm.Email.value,
           "UserID": ReagentReqForm.UserID.value,
           "Reagent": ReagentReqForm.Reagent.value,
           "Quantity": parseInt(ReagentReqForm.Quantity.value),
           "Date": new Date(),
           "Comments": ReagentReqForm.Comments.value,
           "Fulfilled": 'false'
        }],
        success: function(data) {
            window.location =
               '/home/Study/demo/wiki-page.view?name=confirmation&userid='
               + LABKEY.Security.currentUser.id;
        },
    });
    

    Parameters

    • options: QueryRequestOptions

    Returns XMLHttpRequest

    In client-side scripts, this method will return a transaction id for the async request that can be used to cancel the request. In server-side scripts, this method will return the JSON response object (first parameter of the success or failure callbacks).

saveQueryViews

  • saveQueryViews(options: SaveQueryViewsOptions): XMLHttpRequest
  • Creates or updates a custom view or views for a given query in a given schema. The options object matches the viewInfos parameter of the getQueryViews.successCallback.

    Parameters

    • options: SaveQueryViewsOptions

    Returns XMLHttpRequest

saveRows

  • saveRows(options: SaveRowsOptions): XMLHttpRequest
  • Save inserts, updates, and/or deletes to potentially multiple tables with a single request.

    Parameters

    • options: SaveRowsOptions

    Returns XMLHttpRequest

    In client-side scripts, this method will return a transaction id for the async request that can be used to cancel the request. In server-side scripts, this method will return the JSON response object (first parameter of the success or failure callbacks).

selectDistinctRows

selectRows

  • Select rows.

    Examples

    function onFailure(errorInfo, options, responseObj)
    {
        if (errorInfo && errorInfo.exception)
            alert("Failure: " + errorInfo.exception);
        else
            alert("Failure: " + responseObj.statusText);
    }
    
    function onSuccess(data)
    {
        alert("Success! " + data.rowCount + " rows returned.");
    }
    
    LABKEY.Query.selectRows({
       schemaName: 'lists',
       queryName: 'People',
       columns: ['Name', 'Age'],
       success: onSuccess,
       failure: onFailure
    });
    

    Parameters

    Returns XMLHttpRequest

    In client-side scripts, this method will return a transaction id for the async request that can be used to cancel the request. In server-side scripts, this method will return the JSON response object (first parameter of the success or failure callbacks).

sqlDateLiteral

  • sqlDateLiteral(date: Date): string
  • Converts a JavaScript date into a format suitable for using in a LabKey SQL query, does not include time.

    Parameters

    • date: Date

      JavaScript date

    Returns string

    a date literal formatted to be used in a LabKey query

sqlDateTimeLiteral

  • sqlDateTimeLiteral(date: Date, withMS: boolean): string
  • Converts a javascript date into a format suitable for using in a LabKey SQL query, includes time but not milliseconds.

    Parameters

    • date: Date

      JavaScript Date

    • withMS: boolean

      include milliseconds

    Returns string

    a date and time literal formatted to be used in a LabKey query

sqlStringLiteral

  • sqlStringLiteral(str: string): string
  • Converts a JavaScript string into a format suitable for using in a LabKey SQL query. It will properly escape single quote characters.

    Parameters

    • str: string

      String to use in query

    Returns string

    The value formatted for use in a LabKey query.

truncateTable

  • truncateTable(options: QueryRequestOptions): XMLHttpRequest
  • Delete all rows in a table.

    Parameters

    • options: QueryRequestOptions

    Returns XMLHttpRequest

    In client-side scripts, this method will return a transaction id for the async request that can be used to cancel the request. In server-side scripts, this method will return the JSON response object (first parameter of the success or failure callbacks).

updateRows

  • updateRows(options: QueryRequestOptions): XMLHttpRequest
  • Update rows.

    Parameters

    • options: QueryRequestOptions

    Returns XMLHttpRequest

    In client-side scripts, this method will return a transaction id for the async request that can be used to cancel the request. In server-side scripts, this method will return the JSON response object (first parameter of the success or failure callbacks).

validateQuery

  • validateQuery(options: ValidateQueryOptions): XMLHttpRequest
  • Validates the specified query by ensuring that it parses and executes without an exception.

    Parameters

    • options: ValidateQueryOptions

    Returns XMLHttpRequest

    In client-side scripts, this method will return a transaction id for the async request that can be used to cancel the request. In server-side scripts, this method will return the JSON response object (first parameter of the success or failure callbacks).

Generated using TypeDoc