dgraph-rs
dgraph-rs copied to clipboard
Referencing existing UIDs when mutating
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.
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.