import { Cluster } from './cluster' ; import { Collection } from './collection' ; import { CollectionManager } from './collectionmanager' ; import { Connection } from './connection' ; import { PingExecutor } from './diagnosticsexecutor' ; import { PingOptions , PingResult } from './diagnosticstypes' ; import { Scope } from './scope' ; import { StreamableRowPromise } from './streamablepromises' ; import { Transcoder } from './transcoders' ; import { NodeCallback , PromiseHelper } from './utilities' ; import { ViewExecutor } from './viewexecutor' ; import { ViewIndexManager } from './viewindexmanager' ; import { ViewMetaData , ViewQueryOptions , ViewResult , ViewRow , } from './viewtypes' ; category export class Bucket { private _cluster : Cluster ; private _name : string ; private _conn : Connection ; internal constructor ( cluster , bucketName ) { this . _cluster = cluster ; this . _name = bucketName ; this . _conn = cluster . _getConn ( { bucketName : bucketName , } ) ; } internal get conn ( ) : Connection { return this . _conn ; } internal get cluster ( ) : Cluster { return this . _cluster ; } internal get transcoder ( ) : Transcoder { return this . _cluster . transcoder ; } /**
     * The name of the bucket this Bucket object references.
     */ get name ( ) : string { return this . _name ; } param scopeName scope ( scopeName ) { return new Scope ( this , scopeName ) ; } /**
     * Creates a Scope object reference to the default scope.
     */ defaultScope ( ) { return this . scope ( Scope . DEFAULT_NAME ) ; } param collectionName collection ( collectionName ) { const scope = this . defaultScope ( ) ; return scope . collection ( collectionName ) ; } /**
     * Creates a Collection object reference to the default collection.
     */ defaultCollection ( ) { return this . collection ( Collection . DEFAULT_NAME ) ; } /**
     * Returns a ViewIndexManager which can be used to manage the view indexes
     * of this bucket.
     */ viewIndexes ( ) { return new ViewIndexManager ( this ) ; } /**
     * Returns a CollectionManager which can be used to manage the collections
     * of this bucket.
     */ collections ( ) { return new CollectionManager ( this ) ; } param designDoc param viewName param options param callback viewQuery < TValue = any , TKey = any > ( designDoc , viewName , options ? , callback ? ) { if ( options instanceof Function ) { callback = arguments [ 2 ] ; options = undefined ; } if ( ! options ) { options = { } ; } const exec = new ViewExecutor ( this . conn ) ; const options_ = options ; return PromiseHelper . wrapAsync ( ( ) => exec . query < TValue , TKey > ( designDoc , viewName , options_ ) , callback ) ; } param options param callback ping ( options ? , callback ? ) { if ( options instanceof Function ) { callback = arguments [ 0 ] ; options = undefined ; } if ( ! options ) { options = { } ; } const exec = new PingExecutor ( this . conn ) ; const options_ = options ; return PromiseHelper . wrapAsync ( ( ) => exec . ping ( options_ ) , callback ) ; } }