本文整理匯總了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;
}
示例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();
}
}
}
示例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();
}
}
}
示例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();
}