Skip to content

Ndrou/orientjs-steroids

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

orientjs-steroids

OrientJS under steroids.

It's not an OrientJS replacement, it use OrientJS and add new features to the existing.

Features :

  • Generate and execute queries from handlebars templates
  • (...)

New ideas are welcome !

Install

$ npm install orientjs-steroids

Usage

var OrientDB = require('orientjs-steroids');

var server = new OrientDB({
  host: 'localhost',
  port: 2424,
  username: 'root',
  password: 'yourpassword'
});

var db = server.use({
 name: 'GratefulDeadConcerts',
 username: 'admin',
 password: 'admin'
});

See OrientJS Documentation for more details...

Create a template

Simple query

simple-query.hbs

SELECT
  @rid,
  {{#if firstname}}firstname,{{/if}}
  lastname
FROM
  V
WHERE
  lastname = :lastname

Batch query

batch-query.hbs

BEGIN;

let $t0 = select from V WHERE type = :type1;
let $t1 = select from V WHERE type = :type2;

return $t1;

Load query templates

db.loadTemplates({
  path: __dirname + '/templates' // your templates directory
});

Execute a query from template

// See template sample above (Chapter : Create a template)
db.queryTemplate('simple-query', {firstname: true}, {
    params: {
      type: 'song'
    }
  })
  .then(function (results) {
    // (...)
  })

// See template sample above (Chapter : Create a template)
db.batchQueryTemplate('batch-query', null, {
    params: {
      type1: 'song',
      type2: 'artist'
    }
  })
  .then(function (results) {
    // (...)
  })

About

OrientJS under steroids

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published