Mongr
Mongr is graph database built on the document-stored MongoDB and its for Node.js. Mongr using subj-pred-obj triplestores for storing graph data.
example data
subj : 'ali' pred : 'follow' obj : 'buddy'
Install
on Node.js
npm install mongr --save
Usage
Initializing database
var mongr = var db = // example// var db = mongr('mongodb://localhost:27017/graphdb', 'mongr')
Insert
Data which inserted is must be an Array. Insert single or multiple data.
var insertData = subj : 'ali' pred : 'follow' obj : 'ando' subj : 'ando' pred : 'follow' obj : 'eddy' db
Properties
Triplestore can also adding with properties.
var insertData = subj : 'ali' pred : 'follow' obj : 'ando' time : cost : 10 db
Search
Searching graph data. Data must be array.
(subj) -: (pred) -> (obj)
example data
a -: follow -> b
a -: follow -> c
b -: follow -> c
b -: follow -> a
c -: follow -> d
Search who a
follows.
var searchData = subj : 'a' pred : 'follow' obj : '$following' db
Another example, Search who a
follows and following back to 'a'.
var searchData = subj : 'a' pred : 'follow' obj : '$following' subj : '$following' pred : 'follow' obj : 'a' db
Another example, Search who a
follows and not following back to a
.
var searchData = subj : 'a' pred : 'follow' obj : '!$notFolBack' subj : '!$notFolBack' pred : 'follow' obj : 'a' db
Another example, Search follow of follow from a
.
var searchData = subj : 'a' pred : 'follow' obj : '$following' subj : '$following' pred : 'follow' obj : '$followOfFollow' db
Update
Updating multiple data.
db
Delete
Deleting
db