user3936984
user3936984

Reputation:

TypeError: Object #<Object> has no method 'Schema'

This is the schema for our user model. But when I am running in localhost I am getting an error:
TypeError: Object # has no method 'Schema'

// app/models/user.js
// load the things we need
var neo4j = require('neo4j');
var bcrypt   = require('bcrypt-nodejs');

// define the schema for our user model
var userSchema = neo4j.Schema({


    facebook        : {
        id          : String,
        token       : String,
        email       : String,
        firstName   : String,
        lastName    : String
    }

});

// checking if password is valid using bcrypt
userSchema.methods.validPassword = function(password) {
    return bcrypt.compareSync(password, this.local.password);
};


// this method hashes the password and sets the users password
userSchema.methods.hashPassword = function(password) {
    var user = this;

    // hash the password
    bcrypt.hash(password, null, null, function(err, hash) {
        if (err)
            return next(err);

        user.local.password = hash;
    });

};

// create the model for users and expose it to our app
module.exports = neo4j.model('User', userSchema);

This is the error I got from the console:

C:\Users\kiit\WORKSPACE\People Discover App\app\model\user.js:7
var userSchema = neo4j.Schema({
                       ^
TypeError: Object #<Object> has no method 'Schema'
at Object.<anonymous> (C:\Users\kiit\WORKSPACE\People Discover App\app\model\user.js:7:24)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (C:\Users\kiit\WORKSPACE\People Discover App\config\passport.js:8:11)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)

Upvotes: 0

Views: 149

Answers (1)

Dale Corns
Dale Corns

Reputation: 225

I am not sure which library you are using, but there is a clue in your code as to what the issue is, namely:

"neo4j.Schema"

The capital S in Schema, if it exists in the api means that you need to be using the key word new (userSchema = new neo4j.Schema({...), unless of course the api is breaking a cardinal naming rule in javascript. It is possible that schema exist and if it does you would need to change the uppercase S to lowercase s. If neither of these options work, then your api probably does not contain a schema method or a Schema construct.

Upvotes: 1

Related Questions