当前位置: 首页>>代码示例>>Java>>正文


Java DatabaseOptions类代码示例

本文整理汇总了Java中com.couchbase.lite.DatabaseOptions的典型用法代码示例。如果您正苦于以下问题:Java DatabaseOptions类的具体用法?Java DatabaseOptions怎么用?Java DatabaseOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DatabaseOptions类属于com.couchbase.lite包,在下文中一共展示了DatabaseOptions类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUserDatabase

import com.couchbase.lite.DatabaseOptions; //导入依赖的package包/类
private Database getUserDatabase(String name) {
    try {
        String dbName = "db" + StringUtil.MD5(name);
        DatabaseOptions options = new DatabaseOptions();
        options.setCreate(true);
        options.setStorageType(STORAGE_TYPE);
        options.setEncryptionKey(ENCRYPTION_ENABLED ? ENCRYPTION_KEY : null);
        return getManager().openDatabase(dbName, options);
    } catch (CouchbaseLiteException e) {
        Log.e(TAG, "Cannot create database for name: " + name, e);
    }
    return null;
}
 
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:14,代码来源:Application.java

示例2: getAllDocumentIds

import com.couchbase.lite.DatabaseOptions; //导入依赖的package包/类
List<String> getAllDocumentIds(String databaseId) {
    Timber.d("getAllDocumentIds: %s", databaseId);
    ManagerOptions managerOptions = new ManagerOptions();
    managerOptions.setReadOnly(true);

    DatabaseOptions databaseOptions = new DatabaseOptions();
    databaseOptions.setReadOnly(true);

    com.couchbase.lite.Database database = null;
    try {
        // TODO: Create LiveQuery on this?
        // TODO: Open manager/database and cache result - could be expensive operation
        Manager manager = new Manager(new AndroidContext(mContext), managerOptions);
        database = manager.openDatabase(databaseId, databaseOptions);

        List<String> docIds = new ArrayList<>();
        QueryEnumerator result = database.createAllDocumentsQuery().run();
        while (result.hasNext()) {
            QueryRow row = result.next();
            docIds.add(row.getDocumentId());
        }

        return docIds;
    } catch (Exception e) {
        return Collections.emptyList();
    } finally {
        if (database != null) {
            database.close();
        }
    }
}
 
开发者ID:RobotPajamas,项目名称:Stetho-Couchbase,代码行数:32,代码来源:CouchbasePeerManager.java

示例3: getDocument

import com.couchbase.lite.DatabaseOptions; //导入依赖的package包/类
private Map<String, String> getDocument(String databaseId, String docId) {
    Timber.d("getDocument: %s, %s", databaseId, docId);
    DatabaseOptions databaseOptions = new DatabaseOptions();
    databaseOptions.setReadOnly(true);
    com.couchbase.lite.Database database = null;

    try {
        database = mManager.openDatabase(databaseId, databaseOptions);
        Document doc = database.getExistingDocument(docId);
        if (doc == null) {
            return new TreeMap<>();
        }

        Map<String, String> returnedMap = new TreeMap<>();
        for (Map.Entry<String, Object> entry : doc.getProperties().entrySet()) {
            returnedMap.put(entry.getKey(), String.valueOf(entry.getValue()));
        }
        return returnedMap;
    } catch (Exception e) {
        Timber.e(e.toString());
        return new TreeMap<>();
    } finally {
        if (database != null) {
            database.close();
        }
    }
}
 
开发者ID:RobotPajamas,项目名称:Stetho-Couchbase,代码行数:28,代码来源:CouchbasePeerManager.java

示例4: CouchbaseInstance

import com.couchbase.lite.DatabaseOptions; //导入依赖的package包/类
private CouchbaseInstance(Context context) throws CouchbaseLiteException, IOException {
    mContext = context.getApplicationContext();

    DatabaseOptions options = new DatabaseOptions();
    options.setCreate(true);
    options.setStorageType(Manager.FORESTDB_STORAGE);
    Manager manager = new Manager(new AndroidContext(mContext), Manager.DEFAULT_OPTIONS);
    mDatabase = manager.openDatabase(DB_SOLVES, options);

    initApiClient();
}
 
开发者ID:plusCubed,项目名称:plusTimer,代码行数:12,代码来源:CouchbaseInstance.java


注:本文中的com.couchbase.lite.DatabaseOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。