addRelation method

  1. @override
void addRelation(
  1. Relation relation, {
  2. bool replaceIfExists = true,
})
override

Add a new relation to the graph

Implementation

@override
void addRelation(Relation relation, {bool replaceIfExists = true}) {
  final row = _relationToRow(relation);
  if (replaceIfExists) {
    _db.execute('DELETE FROM relations WHERE id = ?', [relation.id]);
    _db.execute(
      'DELETE FROM relation_properties WHERE relationId = ?',
      [relation.id],
    );
  }
  _db.execute(
    'INSERT INTO relations '
    '(id, type, fromNodeId, toNodeId, labelProperty) '
    'VALUES (?, ?, ?, ?, ?)',
    row,
  );
  _saveRelationProperties(relation.id, relation.properties);
}