(
&self,
collection: &str,
id: &str,
embedding: &[f32],
metadata: Option<Document>,
)
| 147 | } |
| 148 | |
| 149 | pub(super) async fn vector_insert_impl( |
| 150 | &self, |
| 151 | collection: &str, |
| 152 | id: &str, |
| 153 | embedding: &[f32], |
| 154 | metadata: Option<Document>, |
| 155 | ) -> NodeDbResult<()> { |
| 156 | let collection = quote_identifier(collection); |
| 157 | let meta_json = match metadata { |
| 158 | Some(d) => sonic_rs::to_string(&d) |
| 159 | .map_err(|e| NodeDbError::storage(format!("metadata serialization: {e}")))?, |
| 160 | None => "{}".into(), |
| 161 | }; |
| 162 | |
| 163 | let sql = format!( |
| 164 | "INSERT INTO {collection} (id, embedding, metadata) VALUES ($1, {}, $2::jsonb)", |
| 165 | format_vector_array(embedding), |
| 166 | ); |
| 167 | self.execute_raw(&sql, &[&id, &meta_json]).await?; |
| 168 | Ok(()) |
| 169 | } |
| 170 | |
| 171 | pub(super) async fn vector_delete_impl(&self, collection: &str, id: &str) -> NodeDbResult<()> { |
| 172 | let collection = quote_identifier(collection); |
no test coverage detected