store<K> method
Stores an entity in this Box. The entity is persisted if this Box implementation is persistent.
Implementation
@override
Future<K> store<K>(dynamic entity) async {
var connection = await _openConnection;
var entitySupport = registry.lookup(entity.runtimeType);
var tableName = _snakeCase(entitySupport.name);
var fieldNames = entitySupport.fields.map((field) => _snakeCase(field));
var fieldValues = _addEntityValues('', {}, entity);
var statement =
'INSERT INTO "$tableName"(${fieldNames.map((field) => '"$field"').join(', ')}) '
'VALUES(${entitySupport.fields.map((field) => _fieldExpression(field, entitySupport.getFieldValue(field, entity))).join(', ')})';
await connection.execute(statement, substitutionValues: fieldValues);
return keyOf(entity);
}