Skip to content

Commit 563d5cd

Browse files
committed
rename lib - add travis and coveralls - add readme
1 parent d756523 commit 563d5cd

6 files changed

Lines changed: 140 additions & 15 deletions

File tree

.coveralls.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
repo_token: UOjQpeYk2baG2Ehj54CukhLdKBIN96Bya

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
coverage/
12
node_modules/
23
*.log

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: node_js
2+
node_js:
3+
- 6
4+
- 7
5+
- 8
6+
- 9
7+
script:
8+
- npm run travis
9+
after_script:
10+
- npm run report-coverage

index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ Graph.prototype.get = function (triple, callback) {
2323
utils.collect(this.getStream(triple), callback)
2424
}
2525

26-
// this is not implemented in hyperdb yet
27-
// for now we just put a null value in the db
28-
Graph.prototype.del = doAction('del')
29-
3026
function doAction (action) {
3127
return function (triples, callback) {
3228
if (!triples) return callback(new Error('Must pass triple'))
@@ -38,10 +34,13 @@ function doAction (action) {
3834
}
3935
}
4036

37+
// this is not implemented in hyperdb yet
38+
// for now we just put a null value in the db
39+
Graph.prototype.del = doAction('del')
40+
4141
Graph.prototype.put = doAction('put')
4242

43-
Graph.prototype.putStream = function (triple) {
44-
}
43+
Graph.prototype.putStream = function (triple) { }
4544

4645
Graph.prototype.searchStream = function (query, options) {
4746
const result = new PassThrough({ objectMode: true })

package.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
{
2-
"name": "hyperdb-graph",
2+
"name": "hyper-graph-db",
33
"version": "0.0.1",
44
"description": "",
55
"main": "index.js",
66
"dependencies": {
7-
"hyperdb": "^1.5.0",
8-
"readable-stream": "^2.3.3"
7+
"hyperdb": "^2.0.0",
8+
"readable-stream": "^2.3.3",
9+
"pump": "^2.0.0"
910
},
1011
"devDependencies": {
1112
"chai": "^4.1.2",
13+
"coveralls": "^3.0.0",
14+
"istanbul": "^0.4.5",
1215
"mocha": "^4.0.1",
13-
"pump": "^2.0.0",
1416
"random-access-memory": "^2.4.0",
1517
"standard": "^10.0.3"
1618
},
1719
"scripts": {
1820
"test": "mocha test/**.spec.js",
19-
"ttd": "mocha test/**.spec.js -w"
21+
"tdd": "mocha test/**.spec.js -w",
22+
"travis": "NODE_ENV=test istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec",
23+
"report-coverage": "cat ./coverage/lcov.info | coveralls"
2024
},
2125
"author": "Benjamin Forster",
2226
"license": "MIT"

readme.md

Lines changed: 114 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,117 @@
1-
# hyperdb-graph [wip]
1+
# hyper-graph-db
22

3-
Not much to see here. Just a spec, failing tests, and the intention to experiment.
3+
[![Build Status](https://travis-ci.org/e-e-e/hyper-graph-db.svg?branch=master)](https://travis-ci.org/e-e-e/hyper-graph-db) [![Coverage Status](https://coveralls.io/repos/github/e-e-e/hyper-graph-db/badge.svg?branch=master)](https://coveralls.io/github/e-e-e/hyper-graph-db?branch=master)
44

5-
The aim is to build a graph database on top of [hyperdb](https://github.com/mafintosh/hyperdb).
5+
hyper-graph-db is a graph database on top of [hyperdb](https://github.com/mafintosh/hyperdb). It interface and test specs have been adapted from [LevelGraph](https://github.com/levelgraph/levelgraph).
66

7-
The test spec is adapted from [LevelGraph](https://github.com/levelgraph/levelgraph).
7+
Like LevelGraph, **hyper-graph-db** follows the **Hexastore** approach as presented in the article: [Hexastore: sextuple indexing for semantic web data management C Weiss, P Karras, A Bernstein - Proceedings of the VLDB Endowment, 2008](http://www.vldb.org/pvldb/1/1453965.pdf). As such hyper-graph-db uses six indices for every triple in order to access them as fast as it is possible.
8+
9+
## install
10+
11+
```
12+
npm install hyper-graph-db
13+
```
14+
15+
This requires node v6.x.x or greater.
16+
17+
## basic usage
18+
19+
```js
20+
var hyperdb = require('hyperdb')
21+
var hypergraph = require('hyper-graph-db')
22+
23+
var db = hypergraph(hyperdb('./my.db', {valueEncoding: 'utf-8'}))
24+
25+
var triple = { subject: 'a', predicate: 'b', object: 'c' }
26+
27+
db.put(triple, function (err) {
28+
if (err) throw err
29+
db.get({ subject: 'a' }, function(err, list) {
30+
console.log(list)
31+
});
32+
})
33+
```
34+
35+
## API
36+
37+
#### `var db = hypergraph(hyperdb)`
38+
39+
Returns an instance of hyper-graph-db using the hyperdb passed to it.
40+
41+
#### `db.put(triple, [callback])`
42+
43+
Inserts **Hexastore** formated entries for triple into the graph database.
44+
45+
#### `var stream = db.putStream(triple)`
46+
47+
Returns a writable stream. **This is not yet implemented!**
48+
49+
#### `db.get(triple, [callback])`
50+
51+
Returns all entries that match the triple. This allows for partial pattern-matching. For example `{ subject: 'a' })`, will return all triples with subject equal to 'a'.
52+
53+
#### `db.del(triple, [callback])`
54+
55+
Remove triples indices from the graph database.
56+
57+
#### `var stream = db.delStream(triple)`
58+
59+
Returns a writable stream for removing entries. **This is not yet implemented!**
60+
61+
#### `var stream = db.getStream(triple)`
62+
63+
Returns a readable stream of all matching triples.
64+
65+
#### `db.search(queries, [callback])`
66+
67+
Allows for Basic Graph Patterns searches where all queries must match.
68+
69+
```js
70+
db.put([{
71+
subject: 'matteo',
72+
predicate: 'friend',
73+
object: 'daniele'
74+
}, {
75+
subject: 'daniele',
76+
predicate: 'friend',
77+
object: 'matteo'
78+
}, {
79+
subject: 'daniele',
80+
predicate: 'friend',
81+
object: 'marco'
82+
}, {
83+
subject: 'lucio',
84+
predicate: 'friend',
85+
object: 'matteo'
86+
}, {
87+
subject: 'lucio',
88+
predicate: 'friend',
89+
object: 'marco'
90+
}, {
91+
subject: 'marco',
92+
predicate: 'friend',
93+
object: 'davide'
94+
}], () => {
95+
96+
const stream = db.search([{
97+
subject: 'matteo',
98+
predicate: 'friend',
99+
object: db.v('x')
100+
}, {
101+
subject: db.v('x'),
102+
predicate: 'friend',
103+
object: db.v('y')
104+
}, {
105+
subject: db.v('y'),
106+
predicate: 'friend',
107+
object: 'davide'
108+
}], (err, results) => {
109+
if (err) throw err
110+
console.log(results)
111+
})
112+
})
113+
```
114+
115+
#### `var stream = db.searchStream(queries)`
116+
117+
Returns search results as a stream.

0 commit comments

Comments
 (0)