npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sails-orientdb-binary

v0.1.1

Published

OrientDB adapter for Sails / Waterline based on Oriento. Can be used through both binary and REST protocols.

Downloads

7

Readme

image_squidhome@2x.png

sails-orientdb adapter

This is a waterline ORM adapter which connects SailsJS app to OrientDB data store. It implements basic CRUD operations on OrientDB using both Binary and REST/HTTP protocols. NOTE: Although the name of this package specifies 'binary', but it supports both protocols (Binary + REST). NPM name was taken when REST support was not implemented, hence the old name continues.

WARNING

This version of the adapter is for the v0.10+ release of Sails / Waterline. It should work with latest Sails version.

Installation

Install from NPM.

# In your app:
$ npm install sails-orientdb-binary

Sails Configuration

Add the OrientDB config to the config/adapters.js file. Basic options:

module.exports.adapters = {
  'default': 'orientdb-bin',

  orientdb-bin: {
    module   : 'sails-orientdb-binary',
    host     : 'localhost',
    port     : 3306,
    user     : 'username',
    password : 'password',
    database : 'OrientDB Database Name'
  }
};

Communicate with OrientDB using Binary & REST Protocols

Using this adapter you can do below CRUD operations on OrientDB classes over binary protocol.

Find: Select record(s) from OrientDB collection / class / table

Example usage: Below example find all those User records where id (in OrientDB its @rid - primary key) is #5:3 and name attribute is 'mike'

User.find({
	where: {
		id: '#5:3',
		name: 'mike'
	}
})
.exec(function (err, result) {
	if (err) {
		console.log("Something went wrong");
	} else {
		console.log("Returned result from server:");
		console.log(result);
		res.json(result);
	}
});

Insert: Add new record to OrientDB collection / class / table

Example usage: Below example inserts new record with four attributes / fields in User collection

User.create({
	name: 'Mike',
	firstName: 'Mike',
	lastName: 'Tyson',
	mobieNumber: '1-805-345-xxx'
})
.exec(function (err, result) {
	if (err) {
		console.log("Something went wrong");
	} else {
		console.log("Record added !");
		res.json(result);
	}
});

Update: Update / change existing record(s) in OrientDB collection / class / table

Example usage: Below example will update lastName and mobileNumber attributes of max 5 records where firstName starts with 'Mike' and email is '[email protected]'

User.update(
	{
		where:{
			firstName: {
				'LIKE': 'Mike'
			},
			email: '[email protected]'
		},
		limit: 5
	},
	{
		lastName: 'Luther',
		mobileNumber: '1-304-555-xxx'
	}
)
.exec(function (err, result) {
	if (err) {
		console.log("Something went wrong");
	} else {
		console.log("Record updated !");
		res.json(result);
	}
});

Destroy: Delete existing record(s) in OrientDB collection / class / table

Example usage: Below example will delete max 5 records where firstName starts with 'Mike' and email is '[email protected]'

User.destroy(
	{
		where:{
			firstName: {
				'LIKE': 'Mike'
			},
			email: '[email protected]'
		},
		limit: 5
	}
)
.exec(function (err, result) {
	console.log("deleted !");
	console.log(result);
	res.json(result);
});

callDBFunction: OrientDB allows you to write function in javascript or SQL which work very similar to stored procedures. We can call such defined function using callDBFunction method of this adapter.

Example usage: Below example calls the defined OrientDB functions getAllStates() with parameter 'India'.

Calling function over Binary Protocol:
User.callDBFunction(
	{
		funcName:"getAllStates",
		params: {
			countryName: "India"
		}
	},
	function (err, result) {
		console.log("Function called !");
		console.log(result);
		res.json(result);
	}
);
Calling OrientDB function over REST / HTTP protocol
var options = {
	funcName: "addUser",
	protocol: "http",
	method: "POST",
	params: {
		firstName: 'Mike',
		lastName: 'Tyson',
		email: '[email protected]'
	}
};

Users.callDBFunction(options, function(err, results) {
	var user;
	if (err) {
		res.json(err.code, err.message);
	} else {
		users = results.result;
		res.json(users);
	}
});

Waterline

Waterline is a brand new kind of storage and retrieval engine.

It provides a uniform API for accessing stuff from different kinds of databases, protocols, and 3rd party APIs. That means you write the same code to get users, whether they live in MySQL, OrientDB, LDAP, MongoDB, or Facebook.

License

MIT © 2014 Gaurav Dhiman, TechZulla & contributors

Sails is free and open-source MVC framework based on [NodeJS] (http://nodejs.org/). It is licensed under the MIT License. OrientDB is free and open-source under the Apache 2. As its open-source, you can get its sources [here] (https://github.com/orientechnologies/orientdb)