npm install TyGuy/sails-neo4j --save
import adapter from 'sails-neo4j' // don't have to call it "adapter", but for consistency with examples.
// OR
var adapter = require('sails-neo4j');
First, create a connection object, to override any defaults (defaults here):
var connection = {
identity: 'neo4j',
username: process.env.NEO4J_USERNAME || 'neo4j',
password: process.env.NEO4J_PASSWORD || 'neo4j'
}
NOTE: The
identity
param is the only one explicitly required. If you are running neo4j locally, and have just set it up (and changed the password when prompted), thenpassword
is most likely the only other thing that needs to change from the default configs
Then, call registerConnection
with the connection object:
adapter.registerConnection(connection, null, callback)
Notes:
- The second argument is unused (I have no idea), so have fun passing whatever you want.
- If you try to register the connection multiple times, you will get an error.
- As with most of the methods here, the callback should be in the form of
function(err, result){}
.
(see here for source)
// adapter.destroy(connection_identity, collection_name, params, callback)
let params = { where: { username: 'tyler' } }
adapter.destroy('neo4j', null, params, function(err, results) {
if (err) { throw err }
return results
});
NOTE: the
params
argument is deceptive, because you need an object with a keywhere
(like{ where: <criteria> }
)
WARNING: Please note that this will actually create and delete nodes in your local neo4j DB. However, They are tagged with the property { "sails_neo4j_test": 1 }, so if you tag any other nodes with that, (that is pretty weird but also) they will be deleted.
npm install
cp .env.sample .env
# IMPORTANT:
# Make sure NEO4J_USERNAME and NEO4J_PASSWORD env vars (in .env file) actually
# match your local neo4j DB credentials; these are needed for basic auth.
npm test
Sails-Neo4j Adapter; Will update the readme very soon. For now if you have any questions: