ether: Only create if !exists
Checks if the app, db, and table exist before creating them.
Change-Id: I8f13d29c84e59d68afef0286e5a6f2db19441833
diff --git a/sky_demo/lib/main.dart b/sky_demo/lib/main.dart
index 003f819..68dc621 100644
--- a/sky_demo/lib/main.dart
+++ b/sky_demo/lib/main.dart
@@ -53,13 +53,18 @@
log('syncbase already initialized');
return;
}
- // TODO(sadovsky): Handle "already exists" case.
var app = _syncbaseClient.app('app');
- await app.create(emptyPerms());
+ if (!(await app.exists())) {
+ await app.create(emptyPerms());
+ }
var db = app.noSqlDatabase('db');
- await db.create(emptyPerms());
+ if (!(await db.exists())) {
+ await db.create(emptyPerms());
+ }
var table = db.table('table');
- await table.create(emptyPerms());
+ if (!(await table.exists())) {
+ await table.create(emptyPerms());
+ }
tb = table;
log('syncbase is now initialized');
}