Add documentation for Databases Plugin

Summary: ^^

Reviewed By: jknoxville

Differential Revision: D15666190

fbshipit-source-id: 4b2f5c5544820baa4654b4e52a7e75bd275facc1
This commit is contained in:
Arnaud Frugier
2019-06-06 11:14:17 -07:00
committed by Facebook Github Bot
parent afe7c8bf25
commit fa887f4f12
6 changed files with 88 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 KiB

View File

@@ -0,0 +1,13 @@
---
id: databases-plugin
title: Databases
---
→ [See setup instructions for the Databases plugin](setup/databases-plugin.md)
The Databases plugin provides developers with read access to their databases: browse the data, see your table's structure and its indexes.
![Databases Plugin 1](/docs/assets/databases-plugin-1.png)
![Databases Plugin 2](/docs/assets/databases-plugin-2.png)
Note: this plugin is only available for Android.

View File

@@ -0,0 +1,63 @@
---
id: databases-plugin
title: Databases Plugin Setup
sidebar_label: Databases
---
To use the databases plugin, you need to add the plugin to your Flipper client instance. The plugin is currently only available for Android.
## Android
Instantiate and add the plugin in `FlipperClient`.
```java
import com.facebook.flipper.plugins.crashreporter.DatabasesPlugin;
client.addPlugin(new DatabasesFlipperPlugin(context));
```
By default it will list all sqlite databases returned by the context. If you are storing a sqlite database somewhere else, you can specify a `File` to it:
```java
client.addPlugin(new DatabasesFlipperPlugin(new SqliteDatabaseDriver(context, new SqliteDatabaseProvider() {
@Override
public List<File> getDatabaseFiles() {
List<File> databaseFiles = new ArrayList<>();
for (String databaseName : context.databaseList()) {
databaseFiles.add(context.getDatabasePath(databaseName));
}
databaseFiles.add("...path_to_your_db...")
return databaseFiles;
}
})));
```
If you use a different type of database other than sqlite, you can implement a driver to be able to access it via Flipper.
```java
client.addPlugin(new DatabasesFlipperPlugin(new DatabaseDriver(context) {
@Override
public List getDatabases() {
return null;
}
@Override
public List<String> getTableNames(DatabaseDescriptor databaseDescriptor) {
return null;
}
@Override
public DatabaseGetTableDataResponse getTableData(DatabaseDescriptor databaseDescriptor, String table, String order, boolean reverse, int start, int count) {
return null;
}
@Override
public DatabaseGetTableStructureResponse getTableStructure(DatabaseDescriptor databaseDescriptor, String table) {
return null;
}
@Override
public DatabaseExecuteSqlResponse executeSQL(DatabaseDescriptor databaseDescriptor, String query) {
return null;
}
}));
```

View File

@@ -63,6 +63,9 @@
"features/crash-reporter-plugin": { "features/crash-reporter-plugin": {
"title": "Crash Reporter" "title": "Crash Reporter"
}, },
"features/databases-plugin": {
"title": "Databases"
},
"features/index": { "features/index": {
"title": "Features" "title": "Features"
}, },
@@ -94,6 +97,10 @@
"title": "Crash Reporter Setup", "title": "Crash Reporter Setup",
"sidebar_label": "Crash Reporter" "sidebar_label": "Crash Reporter"
}, },
"setup/databases-plugin": {
"title": "Databases Plugin Setup",
"sidebar_label": "Databases"
},
"setup/layout-plugin": { "setup/layout-plugin": {
"title": "Layout Inspector Setup", "title": "Layout Inspector Setup",
"sidebar_label": "Layout Inspector" "sidebar_label": "Layout Inspector"
@@ -128,6 +135,9 @@
"tutorial/intro": { "tutorial/intro": {
"title": "Intro" "title": "Intro"
}, },
"tutorial/ios": {
"title": "Building an iOS Plugin"
},
"tutorial/js-custom": { "tutorial/js-custom": {
"title": "Building Custom UI", "title": "Building Custom UI",
"sidebar_label": "Custom UI" "sidebar_label": "Custom UI"

View File

@@ -5,6 +5,7 @@
"features/logs-plugin", "features/logs-plugin",
"features/layout-plugin", "features/layout-plugin",
"features/network-plugin", "features/network-plugin",
"features/databases-plugin",
"features/sandbox-plugin", "features/sandbox-plugin",
"features/shared-preferences-plugin", "features/shared-preferences-plugin",
"features/leak-canary-plugin", "features/leak-canary-plugin",
@@ -20,6 +21,7 @@
"Plugin Setup": [ "Plugin Setup": [
"setup/layout-plugin", "setup/layout-plugin",
"setup/network-plugin", "setup/network-plugin",
"setup/databases-plugin",
"setup/sandbox-plugin", "setup/sandbox-plugin",
"setup/shared-preferences-plugin", "setup/shared-preferences-plugin",
"setup/leak-canary-plugin", "setup/leak-canary-plugin",