
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
dgraph-js-extras
Advanced tools
dgraph-js
and grpc
are needed as peer dependencies.Functions including "commit" indicate they will be set to "commitNow" Functions including "txn" indicate they create their own transactions and can be directly awaited.
This library is pre 1.0 and there might be some small API changes, that said everything is a small function so you could always ctrl-c ctrl-v it out of the repo if things change.
const users = [
{ username: 'foo' }
{ username: 'bar' }
]
const id1 = await xExtractUids(xSetJSONCommitTxn(users, dgraphClient));
const updateJunior = {
skill: 'Javascript',
level: 10,
x: 'y',
y: 'y',
z: 'y'
};
// If you already had a node in the db that looks like:
const existingNode = {
skill: 'Javascript',
level: 10,
x: 'foo',
y: 'foo',
z: 'foo'
};
// You can pass an array of values to update, or just an object.
const updates = [updateJunior];
// The basicEqualityUpsertFn below will find any nodes that has both skill and level predicates.
const upsertFn = basicEqualityUpsertFn(['skill', 'level']);
// x, y and z will be updated from 'foo' to 'y', because both skill and level match.
// If no node matched both skill 'Javascript' and level '10' a new node would be created.
// We can await this direclty as it includes commit and txn postfix.
const [uid] = await xUpsertCommitTxn(upsertFn, updates, dgraphClient);
// It returns the uids of the found or created nodes.
// If you want it as part of a bigger transaction there is also a xUpsertObject function you could use.
Checkout all the functions in API documentation
Please do feel free to submit a PR.
Install docker then run yarn run dgraph-test-db-up
Now just call yarn run test
You can also setup Wallaby JS as a test runner. I am a fan.
yarn run commit
yarn run test
package.json
yarn run generate-changelog
yarn publish
package.json
, CHANGELOG.md
and lib filesFAQs
Functions to use with dgraph
The npm package dgraph-js-extras receives a total of 2 weekly downloads. As such, dgraph-js-extras popularity was classified as not popular.
We found that dgraph-js-extras demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.