#chat #database #backup #full-text

gchdb

Provides a record abstraction for storing chat records extracted by different chat software, and provides full-text search feature

9 releases

0.2.6 Mar 13, 2021
0.2.5 Mar 13, 2021
0.2.2 Feb 27, 2021
0.1.1 Aug 10, 2020
0.1.0 May 21, 2020

#110 in Database implementations

Download history 18/week @ 2021-03-31 9/week @ 2021-04-07 16/week @ 2021-04-14 28/week @ 2021-04-21 9/week @ 2021-04-28 9/week @ 2021-05-12 8/week @ 2021-05-19 10/week @ 2021-06-09 9/week @ 2021-07-14

79 downloads per month

Custom license

35KB
941 lines

GCHDB aka General chat history database

This crate provides chat record abstraction, used to store chat records extracted from different chat software, and integrated Chinese full-text index.

Usage

fn main() -> ChatRecordResult<()> {
    // create an records database
    let mut recoder = SqliteChatRecorder::new("record.db")?;
    // create record, you can extract some record from other im's database
    let record = Record {
        chat_type: "testaasdavxz".into(),
        owner_id: "asdasdasdaaaa".into(),
        group_id: "asdasdasd".into(),
        sender: "人民日报".into(),
        content:
            "张华考上了北京大学;李萍进了中等技术学校;我在百货公司当售货员:我们都有光明的前途"
                .into(),
        timestamp: chrono::Local::now().naive_utc().timestamp_millis(),
        ..Default::default()
    };
    // insert to database
    assert_eq!(recoder.insert_or_update_record(&record)?, true);
    // index the contents of the record
    recoder.refresh_index()?;
    // query record by sql
    println!(
        "{:?}",
        recoder.get_record(Query {
            chat_type: Some("testaasdavxz".into()),
            sender: Some("%日报".into()),
            ..Default::default()
        })?
    );
    // query record by indexer
    println!(
        "{:?}",
        recoder.get_record(Query {
            keyword: Some("技术学校".into()),
            ..Default::default()
        })?
    );
    // remove record in database
    assert_eq!(recoder.remove_record(record)?, true);
    Ok(())
}

Contributing

Welcome pull request :)

License

AGPL3.0

Dependencies

~32MB
~507K SLoC