MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / vector_insert_impl

Method vector_insert_impl

nodedb-client/src/remote/client/vector.rs:149–169  ·  view source on GitHub ↗
(
        &self,
        collection: &str,
        id: &str,
        embedding: &[f32],
        metadata: Option<Document>,
    )

Source from the content-addressed store, hash-verified

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);

Callers 1

vector_insertMethod · 0.45

Calls 2

quote_identifierFunction · 0.85
execute_rawMethod · 0.80

Tested by

no test coverage detected