Provides easy access to orientdb
from Sails.js & Waterline.
The adapter automatically creates edges between model instances with the help of associations information available from Collection instance
This module is a Waterline/Sails adapter, an early implementation of a rapidly-developing, tool-agnostic data standard. Its goal is to provide a set of declarative interfaces, conventions, and best-practices for integrating with all sorts of data sources. Not just databases-- external APIs, proprietary web services, or even hardware.
Strict adherence to an adapter specification enables the (re)use of built-in generic test suites, standardized documentation, reasonable expectations around the API for your users, and overall, a more pleasant development experience for everyone.
To install this adapter, run:
$ npm install sails-orientdb
This adapter exposes the following methods:
- Status
- Completed
- Status
- Completed
- Status
- Completed
- Status
- Completed
Creates edge between specified two model instances by ID in the form parameters "@from" and "@to"
- Status
- Completed
usage:
//Assume a model named "Post"
Post.createEdge('#12:1','#13:1',{'@class':'Comments'},function(err, result){
});
Deletes edges between specified two model instances by ID in the form parameters "@from" and "@to"
- Status
- Completed
usage:
//Assume a model named "Post"
Post.deleteEdges('#12:1','#13:1',null,function(err, result){
});
/**
* User Model
*
* The User model represents the schema of authentication data
*/
module.exports = {
// Enforce model schema in the case of schemaless databases
schema: true,
tableName: 'User',
attributes: {
id: {
type: 'string',
primaryKey: true,
columnName: '@rid'
},
username: {
type: 'string',
unique: true
},
email: {
type: 'email',
unique: true
},
profile: {
collection: 'Profile',
via: 'user',
edge: 'userProfile'
}
}
};
/**
* Profile.js
*
* @description :: TODO: You might write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models
*/
module.exports = {
tableName: 'Profile',
attributes: {
id: {
type: 'string',
primaryKey: true,
columnName: '@rid'
},
user: {
model: "User",
required: true
},
familyName: {
type: 'string'
},
givenName: {
type: 'string'
},
profilePic: {
type: 'string'
}
}
};
An edge names userProfile would be created between user and profile model instances whenever an instance of profile model is saved with user attribute having id of user instance.
Check out Connections in the Sails docs, or see the config/connections.js
file in a new Sails project for information on setting up adapters.
If databas doesn't exist adapter will attempt to create a new one
localOrientDB: {
adapter: 'sails-orientdb',
database: {
name: 'dataBaseName'
},
username: "userName",
password: "password"
}
See FAQ.md
.
- Stackoverflow
- #sailsjs on Freenode (IRC channel)
- Professional/enterprise
- Tutorials
MIT © 2014 vjsrinath & [thanks to] balderdashy, Mike McNeil, Balderdash & contributors
Sails is free and open-source under the MIT License.