rounding shits
This commit is contained in:
@@ -60,6 +60,8 @@ const userDataDB = DatabaseStruct("user_data", {
|
||||
"goal_pin_dates": String,
|
||||
// todo and notes
|
||||
"todo_items": String, "self_notes": String,
|
||||
// v5 shit
|
||||
"roundings": String,
|
||||
});
|
||||
|
||||
Future<void> createTable(Database db, DatabaseStruct struct) =>
|
||||
@@ -118,7 +120,9 @@ Future<Database> initDB(DatabaseProvider database) async {
|
||||
"goal_befores": "{}",
|
||||
"goal_pin_dates": "{}",
|
||||
// todo and notes
|
||||
"todo_items": "{}", "self_notes": "[]"
|
||||
"todo_items": "{}", "self_notes": "[]",
|
||||
// v5 shit
|
||||
"roundings": "{}",
|
||||
});
|
||||
} catch (error) {
|
||||
print("ERROR: migrateDB: $error");
|
||||
|
||||
@@ -305,4 +305,15 @@ class UserDatabaseQuery {
|
||||
.toList();
|
||||
return selfNotes;
|
||||
}
|
||||
|
||||
// v5
|
||||
Future<Map<String, String>> getRoundings({required String userId}) async {
|
||||
List<Map> userData =
|
||||
await db.query("user_data", where: "id = ?", whereArgs: [userId]);
|
||||
if (userData.isEmpty) return {};
|
||||
String? roundingsJson = userData.elementAt(0)["roundings"] as String?;
|
||||
if (roundingsJson == null) return {};
|
||||
return (jsonDecode(roundingsJson) as Map)
|
||||
.map((key, value) => MapEntry(key.toString(), value.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,4 +193,12 @@ class UserDatabaseStore {
|
||||
await db.update("user_data", {"self_notes": selfNotesJson},
|
||||
where: "id = ?", whereArgs: [userId]);
|
||||
}
|
||||
|
||||
// v5
|
||||
Future<void> storeRoundings(Map<String, String> roundings,
|
||||
{required String userId}) async {
|
||||
String roundingsJson = jsonEncode(roundings);
|
||||
await db.update("user_data", {"roundings": roundingsJson},
|
||||
where: "id = ?", whereArgs: [userId]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user