File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,10 +33,23 @@ var levelgraph = require("levelgraph")
3333 , db = n3(levelgraph("yourdb"));
3434```
3535
36+ ### Importing n3 files
37+
38+ ``` js
39+ var fs = require (" fs" );
40+
41+ var stream = fs .createReadStream (" ./triples.n3" )
42+ .pipe (db .n3 .putStream ());
43+
44+ stream .on (" finish" , function () {
45+ console .log (" Import completed" );
46+ });
47+ ```
48+
3649### Get and Put
3750
3851Storing an N3 file in the database is extremey easy:
39- ```
52+ ``` js
4053var turtle = " @prefix c: <http://example.org/cartoons#>.\n " +
4154 " c:Tom a c:Cat.\n " +
4255 " c:Jerry a c:Mouse;\n " +
@@ -49,14 +62,14 @@ db.n3.put(turtle, function(err) {
4962```
5063
5164Retrieving it through pattern-matching is extremely easy:
52- ```
65+ ``` js
5366db .n3 .get ({ subject: " http://example.org/cartoons#Tom" }, function (err , turtle ) {
5467 // turtle is "<http://example.org/cartoons#Tom> a <http://example.org/cartoons#Cat> .\n";
5568});
5669```
5770
5871It even support a Stream interface:
59- ```
72+ ``` js
6073var stream = kdb .n3 .getStream ({ subject: " http://example.org/cartoons#Tom" });
6174stream .on (" data" , function (data ) {
6275 // data is "<http://example.org/cartoons#Tom> a <http://example.org/cartoons#Cat> .\n";
You can’t perform that action at this time.
0 commit comments