Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Query

Index

Type Aliases

CommandType: "delete" | "insert" | "update"
IDataTypes: "datasets" | "queries" | "reports"
ShowRows: "all" | "none" | "paginated" | "selected" | "unselected"

Variables

URL_COLUMN_PREFIX: "_labkeyurl_" = '_labkeyurl_'
containerFilter: typeof ContainerFilter = ContainerFilter
deprecated

Backwards compatible reference to ContainerFilter.

Functions

  • 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

  • Delete specific rows in a table.

    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).

  • 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

    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).

  • Returns details about a given query including detailed information about result columns.

    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).

  • 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).

  • 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

    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).

  • 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

    Returns XMLHttpRequest

  • Save inserts, updates, and/or deletes to potentially multiple tables with a single request.

    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).

  • 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(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(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(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.

  • Delete all rows in a table.

    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).

  • Update rows.

    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).

  • Validates the specified query by ensuring that it parses and executes without an exception.

    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).

Generated using TypeDoc