insertEntry method

Future<bool> insertEntry(
  1. T entry
)

Insert new entry to this table.

Implementation

Future<bool> insertEntry(T entry) async {
  try {
    await entry.beforeSave(true);

    int result = 0;
    var db = await _initializeDB();
    var map = <String, dynamic>{};
    entry.creationTime.value = DateTime.now();
    entry.modificationTime.value = DateTime.now();
    _setEntryToMap(entry, map);
    result = await db.insert(tableName, map);
    entry.id.value = result;
    await entry.afterSave(true);
    _fireChangeListners(EntryChangeType.Insertion, entry);
    return result > 0;
  } catch (e) {
    return false;
  }
}