xExtractNamedUids lets you wrap any of the set commands that return a dgraph assigned value or a promise that returns a dgraph assigned value
const sampleData = {
uid: "_:user",
name: "cameron",
username: "vespertilian",
address: {
uid: "_:address",
street: 'William',
postCode: 2000
}
};
// Wrapping the xSetJSONCommitTxn promise. Nice.
const [userId, addressId] = await xExtractNamedUids(['user', 'address'], xSetJSONCommitTxn(sampleData, dgraphClient))
xExtractUids lets you wrap any of the set commands that return a dgraph assigned value or a promise that returns a dgraph assigned value
const users = [
{ username: 'foo' }
{ username: 'bar' }
]
// Wrapping the xSetJSONCommitTxn promise. Nice.
const [id1, id2] = await xExtractUids(xSetJSONCommitTxn(users, dgraphClient));
Generated using TypeDoc
xExtractFirstUid is useful when you expect only one value and dont want to destructure the returned array. It's effectively just xExtractUids limited to one result
const users = [ { username: 'foo' } { username: 'bar' } ] // Wrapping the xSetJSONCommitTxn promise. Nice. const id1 = await xExtractFirstUid(xSetJSONCommitTxn(users, dgraphClient));