Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add configuration options for storageType for REST API #1431

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/main/java/com/couchbase/lite/router/Router.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.couchbase.lite.ChangesOptions;
import com.couchbase.lite.CouchbaseLiteException;
import com.couchbase.lite.Database;
import com.couchbase.lite.DatabaseOptions;
import com.couchbase.lite.Document;
import com.couchbase.lite.DocumentChange;
import com.couchbase.lite.Manager;
Expand Down Expand Up @@ -1114,8 +1115,23 @@ public Status do_PUT_Database(Database _db, String _docID, String _attachmentNam
}

try {
// note: synchronized
db.open();
Map<String, Object> body = getBodyAsDictionary();
if (body == null) {
Log.i(TAG, "No body for do_PUT_Database");
db.open();
} else {
DatabaseOptions options = new DatabaseOptions();
// ForestDB || SQLite
if (body.containsKey("storageType")) {
String storageType = (String) body.get("storageType");
if (storageType.equals(Manager.SQLITE_STORAGE)
|| storageType.equals(Manager.FORESTDB_STORAGE)) {
Log.d(TAG, "Storage type: " + storageType);
options.setStorageType(storageType);
}
}
db.open(options);
}
} catch (CouchbaseLiteException e) {
return e.getCBLStatus();
}
Expand Down