diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2026-01-22 22:20:15 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-01-22 22:22:40 +0100 |
| commit | 62c3ddf5b722a5e412855b097f7f12a600bb5b78 (patch) | |
| tree | 9fa5214bb7e8d2ff26b7f7c7e7efbc31262b301e /lib | |
| parent | d672e1a6593edb7c324bf90111672bf2e1b2449e (diff) | |
| download | mihi-62c3ddf5b722a5e412855b097f7f12a600bb5b78.tar.gz mihi-62c3ddf5b722a5e412855b097f7f12a600bb5b78.zip | |
words: add the 'dup' subcommand
This is an easy way to create alternatives from existing words.
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/mihi/src/lib.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/mihi/src/lib.rs b/lib/mihi/src/lib.rs index 9d65b1c..e26f220 100644 --- a/lib/mihi/src/lib.rs +++ b/lib/mihi/src/lib.rs @@ -299,6 +299,21 @@ impl TryFrom<isize> for RelationKind { } } +/// Add a row in `word_relations` so the words identified by `one_id` and +/// `other_id` are set to have the `kind` relationship. +pub fn add_word_relationship(one_id: i64, other_id: i64, kind: RelationKind) -> Result<(), String> { + let conn = get_connection()?; + + match conn.execute( + "INSERT INTO word_relations (source_id, destination_id, kind, updated_at, created_at) \ + VALUES (?1, ?2, ?3, datetime('now'), datetime('now'))", + params![one_id, other_id, kind as isize], + ) { + Ok(_) => Ok(()), + Err(e) => Err(e.to_string()), + } +} + /// Join by enunciate the given words. pub fn joint_related_words(related: &[Word]) -> String { related |
