{"id":13555948,"url":"https://github.com/levelgraph/levelgraph-n3","last_synced_at":"2025-03-20T04:50:00.718Z","repository":{"id":9378766,"uuid":"11237374","full_name":"levelgraph/levelgraph-n3","owner":"levelgraph","description":"LevelGraph plugin for storing N3/Turtle/RDF data","archived":false,"fork":false,"pushed_at":"2020-01-29T21:31:24.000Z","size":190,"stargazers_count":36,"open_issues_count":7,"forks_count":8,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-12T19:05:24.503Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/levelgraph.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-07-07T17:52:06.000Z","updated_at":"2022-02-06T16:02:51.000Z","dependencies_parsed_at":"2022-07-11T04:33:21.978Z","dependency_job_id":null,"html_url":"https://github.com/levelgraph/levelgraph-n3","commit_stats":null,"previous_names":["mcollina/levelgraph-n3"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/levelgraph%2Flevelgraph-n3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/levelgraph%2Flevelgraph-n3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/levelgraph%2Flevelgraph-n3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/levelgraph%2Flevelgraph-n3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/levelgraph","download_url":"https://codeload.github.com/levelgraph/levelgraph-n3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244554132,"owners_count":20471173,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T12:03:31.306Z","updated_at":"2025-03-20T04:50:00.699Z","avatar_url":"https://github.com/levelgraph.png","language":"JavaScript","readme":"LevelGraph-N3\n===========\n\n![Logo](https://github.com/levelgraph/node-levelgraph/raw/master/logo.png)\n\n[![Build Status](https://travis-ci.org/levelgraph/levelgraph-n3.png)](https://travis-ci.org/levelgraph/levelgraph-n3)\n[![Coverage Status](https://coveralls.io/repos/levelgraph/levelgraph-n3/badge.png)](https://coveralls.io/r/levelgraph/levelgraph-n3)\n[![Dependency Status](https://david-dm.org/levelgraph/levelgraph-n3.png?theme=shields.io)](https://david-dm.org/levelgraph/levelgraph-n3)\n[![Sauce Labs\nTests](https://saucelabs.com/browser-matrix/levelgraph-n3.svg)](https://saucelabs.com/u/levelgraph-n3)\n\n__LevelGraph-N3__ is a plugin for\n[LevelGraph](http://github.com/levelgraph/levelgraph) that adds the\nability to store, fetch and process N3 and turtle files.\n\n## Install\n\n### Node.js\n\nAdding support for N3 to LevelGraph is easy:\n```shell\n$ npm install level levelgraph levelgraph-n3 --save\n```\nThen in your code:\n```js\nvar level = require('level'),\n    levelgraph = require('levelgraph'),\n    levelgraphN3 = require('levelgraph-n3'),\n    db = levelgraphN3(levelgraph(level('yourdb')));\n```\n\n\n\n### Browser\n\nIf you use [browserify](http://browserify.org/) you can use this package\nin a browser just as in node.js. Please also take a look at [Browserify\nsection in LevelGraph package](https://github.com/levelgraph/levelgraph#browserify)\n\n\n## Usage\n\nWe assume in following examples that you created database as explained\nabove!\n```js\nvar db = levelgraphN3(levelgraph(level(\"yourdb\")));\n```\n\n### Importing n3 files\n\nIn code:\n\n```js\nvar fs = require(\"fs\");\n\nvar stream = fs.createReadStream(\"./triples.n3\")\n               .pipe(db.n3.putStream());\n\nstream.on(\"finish\", function() {\n  console.log(\"Import completed\");\n});\n```\n\nAlternatively, you can run the import CLI tool by running `npm install`, then:\n\n```\n./import.js path/to/n3/file(s)\n```\n\nwith the following optional flags:\n\n`-o` or `--output` followed by the desired DB path. If not specified, path will be at `./db`.\n\n`-q` or `--quiet` will silence status updates during the import process. Otherwise, progress information is displayed.\n\nFile extensions must be `.n3` or `.nt`. Additionally, there is glob support, so for example `*.nt` will import all the matching n-triple files.\n\n\n### Get and Put\n\nStoring an N3 file in the database is extremey easy:\n```js\nvar turtle = \"@prefix c: \u003chttp://example.org/cartoons#\u003e.\\n\" +\n             \"c:Tom a c:Cat.\\n\" +\n             \"c:Jerry a c:Mouse;\\n\" +\n             \"        c:smarterThan c:Tom;\\n\" +\n             \"        c:place \\\"fantasy\\\".\";\n\ndb.n3.put(turtle, function(err) {\n  // do something after the triple is inserted\n});\n```\n\nRetrieving it through pattern-matching is extremely easy:\n```js\ndb.n3.get({ subject: \"http://example.org/cartoons#Tom\" }, function(err, turtle) {\n  // turtle is \"\u003chttp://example.org/cartoons#Tom\u003e a \u003chttp://example.org/cartoons#Cat\u003e .\\n\";\n});\n```\n\nIt even support a Stream interface:\n```js\nvar stream = db.n3.getStream({ subject: \"http://example.org/cartoons#Tom\" });\nstream.on(\"data\", function(data) {\n  // data is \"\u003chttp://example.org/cartoons#Tom\u003e a \u003chttp://example.org/cartoons#Cat\u003e .\\n\";\n});\nstream.on(\"end\", done);\n```\n\n### Exporting NTriples from LevelGraph\n\n__LevelGraph-N3__ allows to export ntriples from a __LevelGraph__ database.\n__LevelGraph-N3__ augments the a standard `search` method with a `{ n3: ... }` option\nthat specifies the subject, predicate and object of the created triples.\nIt follows the same structure of the `{ materialized: ... }` option (see https://github.com/levelgraph/levelgraph#searches).\n\nHere is an example:\n```js\ndb.search([{\n  subject: db.v(\"s\"),\n  predicate: \"http://example.org/cartoons#smarterThan\",\n  object: db.v(\"o\")\n}], {\n  n3: {\n    subject: db.v(\"o\"),\n    predicate: \"http://example.org/cartoons#dumberThan\",\n    object: db.v(\"s\")\n  }\n}, function(err, turtle) {\n  // turtle is \"\u003chttp://example.org/cartoons#Tom\u003e \u003chttp://example.org/cartoons#dumberThan\u003e \u003chttp://example.org/cartoons#Jerry\u003e .\\n\"\n});\n```\n\nIt also supported by the `searchStream` method.\n\n## Changes\n\n[CHANGELOG.md](https://github.com/levelgraph/levelgraph-n3/blob/master/CHANGELOG.md)\n**including migration info for breaking changes**\n\n\n## Contributing to LevelGraph-N3\n\n* Check out the latest master to make sure the feature hasn't been\n  implemented or the bug hasn't been fixed yet\n* Check out the issue tracker to make sure someone already hasn't\n  requested it and/or contributed it\n* Fork the project\n* Start a feature/bugfix branch\n* Commit and push until you are happy with your contribution\n* Make sure to add tests for it. This is important so I don't break it\n  in a future version unintentionally.\n* Please try not to mess with the Makefile and package.json. If you\n  want to have your own version, or is otherwise necessary, that is\n  fine, but please isolate to its own commit so I can cherry-pick around\n  it.\n\n## LICENSE - \"MIT License\"\n\nCopyright (c) 2013-2015 Matteo Collina (http://matteocollina.com)\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the \"Software\"), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":["JavaScript","others","Programming","Misc"],"sub_categories":["JavaScript","BBedit"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flevelgraph%2Flevelgraph-n3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flevelgraph%2Flevelgraph-n3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flevelgraph%2Flevelgraph-n3/lists"}