Manager

Manager

The top-level object that manages Couchbase Lite Databases.

Syntax


@interface CBLManager : NSObject <NSCopying>
class CBLManager : NSObject, NSCopying
public class Manager
public class Manager
public class Manager

Summary


Constants
String
The error domain used for HTTP status codes returned by some APIs.
String
The Couchbase Lite version.
Constructors
Initializes a Manager that stores Databases in the default directory.
Manager(String directory, ManagerOptions options)
Initializes a Manager that stores Databases in the given directory.
Properties
String[]
allDatabaseNames { get; }
Gets the names of all existing Databases.
String
directory { get; }
Gets the directory where the Manager stores Databases.
static Manager
sharedInstance { get; }
Gets a shared, per-process, instance of Manager.
String
storageType { get; set; }
The type of storage engine to be used by default when creating new Databases. Legal values are 'SQLite' or 'ForestDB'. A null value implies 'SQLite'.
Methods
void
close()
Releases all resources used by the Manager and closes all its Databases.
static void
enableLogging(String type, int level)
Enables logging of the specified type at the specified level.
Database
getDatabase(String name)
Returns the Database with the given name. If the Database does not already exist, it is created.
Database
getExistingDatabase(String name)
Returns the Database with the given name if it exists, otherwise null.
static boolean
isValidDatabaseName(String name)
Determines if the given name is a valid Database name. Only the following characters are valid: abcdefghijklmnopqrstuvwxyz0123456789_$()+-/
Database
openDatabase(String name, DatabaseOptions options)
Opens the Database with the given name, using the given options. If the Database is already open, the options are ignored.
void
replaceDatabase(String name, String databaseFile, String attachmentsDirectory)
Replaces or creates a Database from local files.

Constants


String HttpErrorDomain
The error domain used for HTTP status codes returned by some APIs.

Syntax

extern NSString * const CBLHTTPErrorDomain
let CBLHTTPErrorDomain: String!
public final static String HTTP_ERROR_DOMAIN
public final static String HTTP_ERROR_DOMAIN
public static readonly String HttpErrorDomain
String Version
The Couchbase Lite version.

Syntax

extern NSString * CBLVersion(void)
func CBLVersion() -> String!
public final static String VERSION
public final static String VERSION
public static readonly String Version

Constructors


Manager()
Initializes a Manager that stores Databases in the default directory.

Syntax

-(instancetype)init
CBLManager()
// @throws SecurityException
public Manager() throws IOException
// @throws UnsupportedOperationException
public Manager() throws IOException
public Manager()
Manager(String directory, ManagerOptions options)
Initializes a Manager that stores Databases in the given directory.

Parameters

directory The directory to use for storing Databases.
options Option flags for initialization.

Errors

Returns an error if an issue occurs while creating the Manager.

Syntax

-(instancetype)initWithDirectory:(NSString *)directory options:(CBLManagerOptions *)options error:(NSError **)outError
CBLManager(directory: String!, options: UnsafePointer<CBLManagerOptions>, error: NSErrorPointer)
// @throws SecurityException
public Manager(com.couchbase.lite.Context context, ManagerOptions options) throws IOException
public Manager(com.couchbase.lite.Context context, ManagerOptions options) throws IOException
public Manager(DirectoryInfo directory, ManagerOptions options)

Properties


String[] allDatabaseNames { get; }
Gets the names of all existing Databases.

Syntax

@property (readonly) NSArray * allDatabaseNames
var allDatabaseNames: [AnyObject]!
public List<String> getAllDatabaseNames()
public List<String> getAllDatabaseNames()
public IEnumerable<String> AllDatabaseNames { get; }
String directory { get; }
Gets the directory where the Manager stores Databases.

Syntax

@property (readonly) NSString * directory
var directory: String!
public String getDirectory()
public String getDirectory()
public String Directory { get; }
static Manager sharedInstance { get; }
Gets a shared, per-process, instance of Manager.

Syntax

+(CBLManager *)sharedInstance
class func sharedInstance() -> CBLManager!
// @throws SecurityException
public static Manager getSharedInstance() throws IOException
// @throws UnsupportedOperationException
public static Manager getSharedInstance() throws IOException
public static Manager SharedInstance { get; }
String storageType { get; set; }
The type of storage engine to be used by default when creating new Databases. Legal values are 'SQLite' or 'ForestDB'. A null value implies 'SQLite'.

Syntax

@property (copy) NSString *storageType
var storageType: String?
public String getStorageType()
public void setStorageType(String storageType)
public String getStorageType()
public void setStorageType(String storageType)
public string StorageType { get; set; }

Methods


void close()
Releases all resources used by the Manager and closes all its Databases.

Syntax

-(void)close
func close()
public void close()
public void close()
public void Close()
static void enableLogging(String type, int level)
Enables logging of the specified type at the specified level.

Parameters

type The type of logging to enable.
level The level of logging to enable.

Syntax

+(void)enableLogging:(NSString *)type
class func enableLogging(type: String!)
public static void enableLogging(String tag, int level)
public static void enableLogging(String tag, int level)
public static void EnableLogging(int level)
Database getDatabase(String name)
Returns the Database with the given name. If the Database does not already exist, it is created.

Parameters

name The name of the Database to get or create.

Returns

The Database with the given name.

Errors

Returns an error if an issue occurs while getting or creating the Database.

Syntax

-(CBLDatabase *)databaseNamed:(NSString *)name error:(NSError **)outError
func databaseNamed(name: String!, error: NSErrorPointer) -> CBLDatabase!
public Database getDatabase(String name) throws CouchbaseLiteException
public Database getDatabase(String name) throws CouchbaseLiteException
public Database GetDatabase(String name)
Database getExistingDatabase(String name)
Returns the Database with the given name if it exists, otherwise null.

Parameters

name The name of the Database to get.

Returns

The Database with the given name if it exists, otherwise null.

Errors

Returns an error if an issue occurs while getting the Database.

Syntax

-(CBLDatabase *)existingDatabaseNamed:(NSString *)name error:(NSError **)outError
func existingDatabaseNamed(name: String!, error: NSErrorPointer) -> CBLDatabase!
public Database getExistingDatabase(String name) throws CouchbaseLiteException
public Database getExistingDatabase(String name) throws CouchbaseLiteException
public Database GetExistingDatabase(String name)
static boolean isValidDatabaseName(String name)
Determines if the given name is a valid Database name. Only the following characters are valid: abcdefghijklmnopqrstuvwxyz0123456789_$()+-/

Parameters

name The Database name to validate.

Returns

True if the given name is a valid Database name, otherwise False.

Syntax

+(BOOL)isValidDatabaseName:(NSString *)name
class func isValidDatabaseName(name: String!) -> Bool
public static boolean isValidDatabaseName(String name)
public static boolean isValidDatabaseName(String name)
public static Boolean IsValidDatabaseName(String name)
Database openDatabase(String name, DatabaseOptions options)
Opens the Database with the given name, using the given options. If the Database is already open, the options are ignored.

Parameters

name The name of the Database to open.
options Options to use when opening the Database.

Returns

The Database with the given name if it exists or the 'create' option is set, otherwise null.

Errors

Returns an error if an issue occurs while opening the Database.

Syntax

-(CBLDatabase *)openDatabaseNamed:(NSString *)name withOptions:(CBLDatabaseOptions *)options error:(NSError **)outError
func openDatabaseNamed(name: String!, options: CBLDatabaseOptions?, error: NSErrorPointer) -> CBLDatabase!
public Database openDatabase(String name, DatabaseOptions options) throws CouchbaseLiteException
public Database openDatabase(String name, DatabaseOptions options) throws CouchbaseLiteException
public Database OpenDatabase(String name, DatabaseOptions options)
void replaceDatabase(String name, String databaseFile, String attachmentsDirectory)
Replaces or creates a Database from local files.

Parameters

name The name of the target Database to replace or create.
databaseFile Path of the source Database file.
attachmentsDirectory Path of the associated Attachments directory, or null if there are no Attachments.

Errors

Returns an error if an issue occurs while replacing or creating the Database.

Syntax

-(BOOL)replaceDatabaseNamed:(NSString *)databaseName withDatabaseFile:(NSString *)databasePath withAttachments:(NSString *)attachmentsPath error:(NSError **)outError
func replaceDatabaseNamed(databaseName: String!, withDatabaseFile: String!, withAttachments: String!, error: NSErrorPointer) -> Bool
public void replaceDatabase(String databaseName, InputStream databaseStream, Map<String,InputStream> attachmentStreams) throws CouchbaseLiteException
public void replaceDatabase(String databaseName, InputStream databaseStream, Map<String,InputStream> attachmentStreams) throws CouchbaseLiteException
public Boolean ReplaceDatabase(String name, FileInfo databaseFile, DirectoryInfo attachmentsDirectory)