insert method

  1. @override
Future<int?> insert(
  1. String fromAtSign,
  2. String verbName, {
  3. String? lookupKey,
})
override

Append a new entry recording that fromAtSign performed verbName (optionally against lookupKey) at the current instant. Returns the assigned entry id, or null on failure.

Implementation

@override
Future<int?> insert(String fromAtSign, String verbName,
    {String? lookupKey}) async {
  return _db.runInTransaction(() {
    _db.raw.execute(
      'INSERT INTO access_log (from_atsign, request_at, verb_name, lookup_key) '
      'VALUES (?, ?, ?, ?);',
      [
        fromAtSign,
        DateTime.now().toUtc().millisecondsSinceEpoch,
        verbName,
        lookupKey
      ],
    );
    return _db.raw.select('SELECT last_insert_rowid() r;').first['r'] as int;
  });
}