insertDailyLog method
insert daily logs report based on userId and log date
Implementation
Future<int> insertDailyLog(
Map<String, dynamic> data, String logDate, String customerId) async {
Database? db = await instance.database;
/// Check if found logs on provided date
int? recordExist = Sqflite.firstIntValue(await db!.rawQuery(
"SELECT COUNT(*) FROM $tableDailyUserSymptomsLogsData WHERE $columnLogDate='$logDate' AND $columnCustomerId='$customerId'"));
printMenstrualCycleLogs("Found Data logDate : $logDate");
printMenstrualCycleLogs("Found Data customerId : $customerId");
printMenstrualCycleLogs("Found Data recordExist : $recordExist");
if (recordExist! > 0) {
/// remove old logs
await db.rawDelete(
"DELETE FROM $tableDailyUserSymptomsLogsData WHERE $columnLogDate='$logDate' AND $columnCustomerId='$customerId'");
////printMenstrualCycleLogs("Delete Data");
}
///insert a new logs
int id = await db.insert(tableDailyUserSymptomsLogsData, data);
printMenstrualCycleLogs("Insert Data");
return id;
}