I'm using the node-neo4j library along with node.js, underscore and prototype.
I'm trying to have a model which extends a database adapter. Code first.
BaseModel.js:
var _ = require("underscore"),
    Neo4jAdapter = require('../adapters/neo4j/Adapter');
function BaseModel() {
    _.extend(this, new Neo4jAdapter());
};
module.exports = BaseModel;
Neo4jAdapter.js:
var _ = require("underscore"),
    Neo4j = require('neo4j');
function Neo4jAdapter() {
    this.db = new Neo4j.GraphDatabase('http://localhost:3000');
};
Neo4jAdapter.prototype.insert = function(label, data, callback) {
    console.log('Neo4jAdapter', 'Attempt to insert node');
    if (label == '') throw 'Label is not defined';
    var query = [
        'CREATE (n:LABEL {mdata})',
        'RETURN n'
    ].join('\n').replace('LABEL', label);
    this.db.query(query, data, function (err, results) {
        if (err) throw err;
        console.log(results);
        var result = results[0].n._data.data;
        result.id = results[0].n._data.metadata.id;
        callback(result);
    });
};
module.exports = Neo4jAdapter;
The weird thing is the error I'm getting. I won't post all the node.js / express code here, but I'm hitting the insert function with an url. The response I get is the following:
Message: Object #
GraphDatabase has no method 'query'
Error: TypeError: Object #
GraphDatabase has no method 'query'
My question is: Why does the database object does not have the function query(), even tho the docs are saying it should have one?
Possible cause: I bet the adapter's db object is not populated yet when calling the insert method, but how do I do that?
Thanks