dgraph-rs icon indicating copy to clipboard operation
dgraph-rs copied to clipboard

Referencing existing UIDs when mutating

Open throwawaybanana opened this issue 3 years ago • 1 comments

I'm having issues when trying to mutate things in the database

let c = MutComment {
    content: comment.content.clone(),
    poster,
    thread,
    attachment: attachment,
    post_time: "2019-04-11T01:45:00Z".to_string(), // ignore this, it's placeholder
  };

both poster and thread are supposed to be references to another node's UID, which I have stored as strings but when trying to mutate it this way the function creates the request as them being actual strings, instead of scalar values ie. <0x14c2>.

Is there a way to force it to handle these strings as scalar values? And if not, how are the RDF mutation requests formatted? I tried doing that because this wasn't working out, where I would just replace parts of the string with the correct values but the DB really didn't like me formatting the RDF the same way I would when using the Ratel Web UI. I tried removing a few levels of {} from the string but that didn't make a difference.

throwawaybanana avatar Mar 22 '21 08:03 throwawaybanana

Hey, sorry for a late reply!

You can set nquads directly in mutation, eg.:

let mut mutation = dgraph::Mutation::new();
mutation.set_set_nquads("<0x1> <poster> <0x2> .".to_string().into_bytes());

I'm not 100% sure right now if there's any way to set those IDs in structures.

ondrowan avatar Apr 08 '21 13:04 ondrowan