UNPKG

livia-titan

Version:

Titan adapter for universal database driver Livia

43 lines (32 loc) 955 B
import _ from 'lodash'; import { Adapter, Model } from 'livia'; import Query from './Query'; import { waterfall, each } from 'async'; import extend from 'node.extend'; import debug from 'debug'; import path from 'path'; import Titan from 'titan-node'; const log = debug('livia-orientdb:adapter'); export default class OrientDBAdapter extends Adapter { constructor(options) { super(options); } get g() { return this._g; } connect(callback) { var gremlin = new Titan.Gremlin({ loglevel: 'OFF' }); var GraphOfTheGodsFactory = gremlin.java.import('com.thinkaurelius.titan.example.GraphOfTheGodsFactory'); var graph = GraphOfTheGodsFactory.createSync('testdirectory'); this._g = gremlin.wrap(graph); callback(); } query (model, options) { return new Query(model, options); } ensureIndex(model, OClass, callback) { } ensureClass(model, callback) { callback(null, model); } };