GithubHelp home page GithubHelp logo

fridaystreet / orientjs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from orientechnologies/orientjs

0.0 2.0 0.0 1.62 MB

The official fast, lightweight node.js client for OrientDB

Home Page: http://orientdb.com

License: Other

JavaScript 99.49% Shell 0.51%

orientjs's Introduction

OrientJS driver

Official orientdb driver for node.js. Fast, lightweight, uses the binary protocol.

Master: Build Status

Develop: Build Status

NOTE: Release v2.2 contains big improvement on marshalling by using native C driver.

Features

  • Tested with latest OrientDB (2.0.x and 2.1).
  • Intuitive API, based on bluebird promises.
  • Fast binary protocol parser.
  • Distributed Support
  • Access multiple databases via the same socket.
  • Migration support.
  • Simple CLI.
  • Connection Pooling

Documentation

Main Topics

Supported Versions

OrientJS aims to work with version 2.0.0 of OrientDB and later. While it may work with earlier versions, they are not currently supported, pull requests are welcome!

IMPORTANT: OrientJS does not currently support OrientDB's Tree Based RIDBag feature because it relies on making additional network requests. This means that by default, the result of e.g. JSON.stringify(record) for a record with up to 119 edges will be very different from a record with 120+ edges. This can lead to very nasty surprises which may not manifest themselves during development but could appear at any time in production. There is an open issue for this in OrientDB, until that gets fixed, it is strongly recommended that you set RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD to a very large value, e.g. 2147483647. Please see the relevant section in the OrientDB manual for more information.

Installation

Install via npm.

npm install orientjs

To install OrientJS globally use the -g option:

npm install orientjs -g

Running Tests

To run the test suite, first invoke the following command within the repo, installing the development dependencies:

npm install

Then run the tests:

npm test

##CLI

An extremely minimalist command line interface is provided to allow databases to created and migrations to be applied via the terminal.

To be useful, OrientJS requires some arguments to authenticate against the server. All operations require the password argument unless the user is configured with an empty password. For operations that involve a specific db, include the dbname argument (with dbuser and dbpassword if they are set to something other than the default).

You can get a list of the supported arguments using orientjs --help.

  -d, --cwd         The working directory to use.
  -h, --host        The server hostname or IP address.
  -p, --port        The server port.
  -u, --user        The server username.
  -s, --password    The server password.
  -n, --dbname      The name of the database to use.
  -U, --dbuser      The database username.
  -P, --dbpassword  The database password.
  -?, --help        Show the help screen.

If it's too tedious to type these options in every time, you can also create an orientjs.opts file containing them. OrientJS will search for this file in the working directory and apply any arguments it contains. For an example of such a file, see test/fixtures/orientjs.opts.

Note: For brevity, all these examples assume you've installed OrientJS globally (npm install -g orientjs) and have set up an orientjs.opts file with your server and database credentials.

Database CLI Commands.

Listing all the databases on the server.

orientjs db list

Creating a new database

orientjs db create mydb graph plocal

Destroying an existing database

orientjs db drop mydb

Migrations

OrientJS supports a simple database migration system. This makes it easy to keep track of changes to your orientdb database structure between multiple environments and distributed teams.

When you run a migration command, OrientJS first looks for an orient class called Migration. If this class doesn't exist it will be created. This class is used to keep track of the migrations that have been applied.

OrientJS then looks for migrations that have not yet been applied in a folder called migrations. Each migration consists of a simple node.js module which exports two methods - up() and down(). Each method receives the currently selected database instance as an argument.

The up() method should perform the migration and the down() method should undo it.

Note: Migrations can incur data loss! Make sure you back up your database before migrating up and down.

In addition to the command line options outlined below, it's also possible to use the migration API programatically:

var db = server.use('mydb');

var manager = new OrientDB.Migration.Manager({
  db: db,
  dir: __dirname + '/migrations'
});

manager.up(1)
.then(function () {
  console.log('migrated up by one!')
});

Listing the available migrations

To list all the unapplied migrations:

orientjs migrate list

Creating a new migration

orientjs migrate create my new migration

creates a file called something like m20140318_200948_my_new_migration which you should edit to specify the migration up and down methods.

Migrating up fully

To apply all the migrations:

orientjs migrate up

Migrating up by 1

To apply only the first migration:

orientjs migrate up 1

Migrating down fully

To revert all migrations:

orientjs migrate down

Migrating down by 1

orientjs migrate down 1

##Troubleshooting

  • Node exception Maximum call stack size exceeded here

History

In 2012, Gabriel Petrovay created the original node-orientdb library, with a straightforward callback based API.

In early 2014, Giraldo Rosales made a whole host of improvements, including support for orientdb 1.7 and switched to a promise based API.

Later in 2014, codemix refactored the library to make it easier to extend and maintain, and introduced an API similar to nano. The result is so different from the original codebase that it warranted its own name and npm package. This also gave us the opportunity to switch to semantic versioning.

In June 2015, Orient Technologies company officially adopted the Oriento driver and renamed it as OrientJS.

Notes for contributors

Please see CONTRIBUTING.

Changes

See CHANGELOG

License

Apache 2.0 License, see LICENSE

orientjs's People

Contributors

phpnode avatar ffissore avatar gabipetrovay avatar wolf4ood avatar samsonradu avatar lvca avatar nitrogenlabs avatar orangemug avatar matanshukry avatar luigidellaquila avatar kelvin-ng avatar dmarcelino avatar dehbmarques avatar volune avatar seeden avatar tglman avatar bbtx0 avatar mamobyz avatar ionicabizau avatar rschmukler avatar welcomattic avatar nitrog7 avatar cpixl avatar saeedtabrizi avatar morkai avatar ziink avatar prasad83 avatar martingg88 avatar kgreenpea avatar jpstrikesback avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.