Home Reference Source Test Repository
import Bucket from 'kinto-client/lib/bucket.js'
public class | source

Bucket

Abstract representation of a selected bucket.

Test:

Constructor Summary

Public Constructor
public

constructor(client: KintoClient, name: String)

Constructor.

Member Summary

Public Members
public

The bucket name.

Method Summary

Public Methods
public

batch(fn: Function, options: Object): Promise<Object, Error>

Performs batch operations at the current bucket level.

public

collection(name: String, options: Object): Collection

Selects a collection.

public

Creates a new collection in current bucket.

public

createGroup(id: String | undefined, members: Array<String>, options: Object): Promise<Object, Error>

Creates a new group in current bucket.

public

deleteCollection(collection: Object | String, options: Object): Promise<Object, Error>

Deletes a collection from the current bucket.

public

Deletes a group from the current bucket.

public

Retrieves bucket data.

public

Creates a new group in current bucket.

public

Retrieves the list of permissions for this bucket.

public

Retrieves the list of collections in the current bucket.

public

Retrieves the list of groups in the current bucket.

public

setData(data: Object, options: Object): Promise<Object, Error>

Set bucket data.

public

setPermissions(permissions: Object, options: Object, options: Object): Promise<Object, Error>

Recplaces all existing bucket permissions with the ones provided.

public

updateGroup(group: Object, options: Object): Promise<Object, Error>

Updates an existing group in current bucket.

Public Constructors

public constructor(client: KintoClient, name: String) source

Constructor.

Params:

NameTypeAttributeDescription
client KintoClient

The client instance.

name String

The bucket name.

options.headers Object

The headers object option.

options.safe Boolean

The safe option.

Public Members

public name: String source

The bucket name.

Public Methods

public batch(fn: Function, options: Object): Promise<Object, Error> source

Performs batch operations at the current bucket level.

Params:

NameTypeAttributeDescription
fn Function

The batch operation function.

options Object

The options object.

options.headers Object

The headers object option.

options.safe Boolean

The safe option.

options.aggregate Boolean

Produces a grouped result object.

Return:

Promise<Object, Error>

Test:

public collection(name: String, options: Object): Collection source

Selects a collection.

Params:

NameTypeAttributeDescription
name String

The collection name.

options Object

The options object.

options.headers Object

The headers object option.

options.safe Boolean

The safe option.

Return:

Collection

Test:

public createCollection(id: String | undefined, options: Object): Promise<Object, Error> source

Creates a new collection in current bucket.

Params:

NameTypeAttributeDescription
id String | undefined

The collection id.

options Object

The options object.

options.safe Boolean

The safe option.

options.headers Object

The headers object option.

options.permissions Object

The permissions object.

options.data Object

The data object.

Return:

Promise<Object, Error>

Test:

public createGroup(id: String | undefined, members: Array<String>, options: Object): Promise<Object, Error> source

Creates a new group in current bucket.

Params:

NameTypeAttributeDescription
id String | undefined

The group id.

members Array<String>

The list of principals.

options Object

The options object.

options.data Object

The data object.

options.permissions Object

The permissions object.

options.safe Boolean

The safe option.

options.headers Object

The headers object option.

Return:

Promise<Object, Error>

Test:

public deleteCollection(collection: Object | String, options: Object): Promise<Object, Error> source

Deletes a collection from the current bucket.

Params:

NameTypeAttributeDescription
collection Object | String

The collection to delete.

options Object

The options object.

options.headers Object

The headers object option.

options.safe Boolean

The safe option.

Return:

Promise<Object, Error>

Test:

public deleteGroup(group: Object | String, options: Object): Promise<Object, Error> source

Deletes a group from the current bucket.

Params:

NameTypeAttributeDescription
group Object | String

The group to delete.

options Object

The options object.

options.headers Object

The headers object option.

options.safe Boolean

The safe option.

Return:

Promise<Object, Error>

public getData(options: Object): Promise<Object, Error> source

Retrieves bucket data.

Params:

NameTypeAttributeDescription
options Object

The options object.

options.headers Object

The headers object option.

Return:

Promise<Object, Error>

Test:

public getGroup(id: String, options: Object): Promise<Object, Error> source

Creates a new group in current bucket.

Params:

NameTypeAttributeDescription
id String

The group id.

options Object

The options object.

Return:

Promise<Object, Error>

Test:

public getPermissions(options: Object): Promise<Object, Error> source

Retrieves the list of permissions for this bucket.

Params:

NameTypeAttributeDescription
options Object

The options object.

options.headers Object

The headers object option.

Return:

Promise<Object, Error>

Test:

public listCollections(options: Object): Promise<Array<Object>, Error> source

Retrieves the list of collections in the current bucket.

Params:

NameTypeAttributeDescription
options Object

The options object.

options.headers Object

The headers object option.

Return:

Promise<Array<Object>, Error>

Test:

public listGroups(options: Object): Promise<Array<Object>, Error> source

Retrieves the list of groups in the current bucket.

Params:

NameTypeAttributeDescription
options Object

The options object.

options.headers Object

The headers object option.

Return:

Promise<Array<Object>, Error>

Test:

public setData(data: Object, options: Object): Promise<Object, Error> source

Set bucket data.

Params:

NameTypeAttributeDescription
data Object

The bucket data object.

options Object

The options object.

options.headers Object

The headers object option.

options.safe Boolean

The safe option.

options.patch Boolean

The patch option.

Return:

Promise<Object, Error>

public setPermissions(permissions: Object, options: Object, options: Object): Promise<Object, Error> source

Recplaces all existing bucket permissions with the ones provided.

Params:

NameTypeAttributeDescription
permissions Object

The permissions object.

options Object

The options object

options Object

The options object.

options.safe Boolean

The safe option.

options.headers Object

The headers object option.

options.last_modified Object

The last_modified option.

Return:

Promise<Object, Error>

Test:

public updateGroup(group: Object, options: Object): Promise<Object, Error> source

Updates an existing group in current bucket.

Params:

NameTypeAttributeDescription
group Object

The group object.

options Object

The options object.

options.data Object

The data object.

options.permissions Object

The permissions object.

options.safe Boolean

The safe option.

options.headers Object

The headers object option.

Return:

Promise<Object, Error>

Test: