Hade du nytta av den här sidan?
Din feedback om det här innehållet är viktig. Berätta vad du tycker.
Ytterligare feedback?
1500 tecken kvar
Exportera (0) Skriv ut
Visa allt
EN
Det här innehållet finns inte tillgängligt på ditt språk men här finns den engelska versionen,

tables object

Updated: February 25, 2015

Provides functionality for working with specific tables as a table object instance.

This object contains the following members:

getTable

Syntax Returns Description

tables.getTable(tableName)

table object

Returns the specified tableName as a table object.

current

Syntax Returns Description

tables.current

table object

Returns the current table as a table object.

Call the getTable method on the global tables object to get a table object that represents a specific tableName.

The current property on the global tables object gets a table object that represents the current table.

The following script calls the getTable method to get the permissions table against which to execute queries.

function insert(item, user, request) {
    var permissionsTable = tables.getTable('permissions');

    permissionsTable.where({
        userId: user.userId,
        permission: 'submit order'
    }).read({
        success: function(results) {
            if (results.length > 0) {
                // Permission record was found. Continue normal execution.
                request.execute();
            } else {
                console.log('User %s attempted to submit an order without permissions.', user.userId);
                request.respond(statusCodes.FORBIDDEN, 'You do not have permission to submit orders.');
            }
        }
    });
}

The following script shows usage of the current property in validation logic.

function insert(item, user, request) {
    var currentTable = tables.current;
    currentTable.where({ name: item.name }).read({
        success: function (items) {
            if (items.length > 0) {
                request.respond(400, { error: 'Item with this name already exists' });
            } else {
                request.execute();
            }
        }
    });
}

Visa:
© 2015 Microsoft