Last active
April 25, 2017 21:13
-
-
Save reicheltp/4cc667e15a17fad124b1ddc33865c59f to your computer and use it in GitHub Desktop.
node-dgraph-mutation.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let setReq = new Request(); | |
| setReq.mutation = new Mutation(); | |
| // a string value nquad | |
| let nqName = new NQuad(); | |
| nqName.subject = 'paul'; | |
| nqName.predicate = 'name'; | |
| nqName.objectValue = new Value().set('str_val', 'Paul Reichelt'); | |
| nqName.objectType = 10; | |
| // a float value nquad | |
| let nqAge = new NQuad(); | |
| nqAge.subject = 'paul'; | |
| nqAge.predicate = 'size'; | |
| nqAge.objectValue = new Value().set('double_val', 1.85); | |
| nqAge.objectType = 3; | |
| // add all nquads to the request's mutation | |
| setReq.mutation.set.push(nqName); | |
| setReq.mutation.set.push(nqAge); | |
| // execute the request | |
| dgraph.run(setReq, (err, res) => console.log(err || res)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment