當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。