Closed sukechris closed 2 years ago
Hey @sukechris, welcome! You got this sorted?
@billy1624 I don't know how to solve it with sea-orm for now,but I realized this issue may not be related to sea-orm,It's possible to solve it by native sqlite query with json_each
or json_tree
,and I'll try it later
Got it! Thanks for the updates :P
Thanks for the tips, I was able to use the following:
let db = self.connect().await.unwrap();
let files = MyTable::find()
.from_raw_sql(
Statement::from_sql_and_values(
DbBackend::Sqlite,
r#"SELECT * FROM mytable WHERE json_extract(my_table.json_field, $1) = $2"#,
vec![json_field_key.into(), json_field_value.into()],
)
)
.all(&db)
.await.map_err(OrmError::DatabaseQueryError)?;
Ok(files)
Thank you for your great work! I encountered a problem, I have a field in my sqlite table, and this field is tree structure json data, like this:
I want to query
title
value by keyword, Is there a good way to achieve it?