addRelation method
Add a new relation to the graph
Implementation
@override
void addRelation(Relation relation, {bool replaceIfExists = true}) {
if (!replaceIfExists && relationExists(relation.id)) {
return;
}
final row = _relationToRow(relation);
_transaction(() {
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);
});
}