Options
All
  • Public
  • Public/Protected
  • All
Menu

Class KiiBucket

Represents a KiiBucket object

Hierarchy

Index

Properties

bucketName: string

Methods

  • Get the ACL handle for this bucket

    Any KiiACLEntry objects added or revoked from this ACL object will be appended to/removed from the server on ACL save.

    example
    const bucket = . . .; // a KiiBucket
    const acl = bucket.acl();

    Returns KiiACL

    A KiiACL object associated with this KiiBucket

  • Execute count aggregation of all clause query on current bucket.

    example
    let bucket = . . .; // a KiiBucket
    let queryObject = . . .; // a KiiQuery

    bucket.count().then(params => {
    let bucket = params[0];
    let query = params[1];
    let count = params[2];
    // do something with the results
    }).catch(error => {
    let bucket = error.target;
    let errorString = error.message;
    // error happened.
    });

    Returns Promise<[KiiBucket, null | KiiQuery, number]>

    return promise object.

    • fulfill callback function: function(params). params is Array instance.
      • params[0] is a KiiBucket instance which this method was called on.
      • params[1] is a KiiQuery instance.
      • params[2] is an integer count result.
    • reject callback function: function(error). error is an Error instance.
      • error.target is the KiiBucket instance which this method was called on.
      • error.message

  • Execute count aggregation of specified query on current bucket. Query that passed as nextQuery in success callback of executeQuery, is not supported, callbacks.failure will be fired in this case.

    example
    let bucket = . . .; // a KiiBucket
    let queryObject = . . .; // a KiiQuery

    bucket.countWithQuery(queryObject, callbacks).then(params => {
    let bucket = params[0];
    let query = params[1];
    let count = params[2];
    // do something with the results
    }).catch(error => {
    let bucket = error.target;
    let errorString = error.message;
    // error happened.
    });

    Parameters

    • query: null | KiiQuery

      query to be executed. If null, the operation will be same as count.

    Returns Promise<[KiiBucket, null | KiiQuery, number]>

    return promise object.

    • fulfill callback function: function(params). params is Array instance.
      • params[0] is a KiiBucket instance which this method was called on.
      • params[1] is a KiiQuery instance.
      • params[2] is an integer count result.
    • reject callback function: function(error). error is an Error instance.
      • error.target is the KiiBucket instance which this method was called on.
      • error.message

  • Create a KiiObject within the current bucket

    example
    let bucket = . . .; // a KiiBucket
    let object = bucket.createObject();

    Returns KiiObject

    An empty KiiObject with no specific type

  • createObjectWithID(objectID: string): KiiObject
  • Create a KiiObject within the current bucket, specifying its ID.

    throws

    {InvalidArgumentException} objectID is not acceptable. Refer to KiiObject.isValidObjectID for details of acceptable string.

    example
    let bucket = . . .; // KiiBucket
    let object = bucket.createObjectWithID('__OBJECT_ID_');

    Parameters

    • objectID: string

      ID of the obeject you want to instantiate.

    Returns KiiObject

    KiiObject instance.

  • createObjectWithType(type: string): KiiObject
  • Create a KiiObject within the current bucket, with type

    example
    const bucket = . . .; // a KiiBucket
    const object = bucket.createObjectWithType("scores");

    Parameters

    • type: string

      representing the desired object type

    Returns KiiObject

    An empty KiiObject with specified type

  • delete(): Promise<void>
  • Delete the given bucket from the server

    example
    let bucket = . . .; // a KiiBucket
    bucket.delete().then(() => {
    // do something with the result
    }).catch(error => {
    // do something with the error response
    });

    Returns Promise<void>

    return promise object.

    • fulfill callback function:
    • reject callback function: function(error). error is an Error instance.
      • error.target is the KiiBucket instance which this method was called on.
      • error.message

  • Perform a query on the given bucket

    The query will be executed against the server, returning a result set.

    example
    let bucket = . . .; // a KiiBucket
    let queryObject = . . .; // a KiiQuery
    bucket.executeQuery(queryObject).then(params => {
    let queryPerformed = params[0];
    let resultSet = params[1];
    let nextQuery = params[2];
    // do something with the results
    for (let i = 0; i < resultSet.length; i++) {
    // do something with the object
    // resultSet[i]; // could be KiiObject, KiiGroup, KiiUser, etc
    }

    // if there are more results to be retrieved
    if(nextQuery != null) {
    // get them and repeat recursively until no results remain
    bucket.executeQuery(nextQuery).then(params => {
    // next query success
    }).catch(error => {
    // next query failed, please handle the error
    });
    }
    }).catch(error => {
    // do something with the error response
    });

    Parameters

    • query: KiiQuery

      An object with callback methods defined

    Returns Promise<[KiiQuery, KiiObject[], null | KiiQuery]>

    return promise object.

    • fulfill callback function: function(params). params is Array instance.
      • params[0] is a performed KiiQuery instance.
      • params[1] is resultSet Array instance. Could be KiiObject, KiiGroup, KiiUser, etc.
      • params[2] is a KiiQuery instance for next query. If there are no more results to be retrieved, it will be null.
    • reject callback function: function(error). error is an Error instance.
      • error.target is the KiiBucket instance which this method was called on.
      • error.message

  • getBucketName(): string

Generated using TypeDoc