readme demo isnt working
itzikorfa opened this issue · 3 comments
Hi
I'm trying to use the module on my neo4j project
but when I work by the guide I get errors about the module
the way I import it and.
is there a working demo that can I run?
the error I get are:
import Neode from 'neode'; ^^^^^ SyntaxError: Unexpected identifier
TypeError: neode.model is not a function
It looks like you need to create an instance of neode. Can I see your full code please?
the code I took from the article :
https://medium.com/neo4j/interacting-with-neo4j-in-nodejs-using-the-neode-object-mapper-3d99cb324546
my code is:
`import Neode from 'neode';
const instance = new Neode('bolt://localhost:7687', 'neo4j', '123456');
instance.model('Person', {
person_id: {
primary: true,
type: 'uuid',
// Creates an Exists Constraint in Enterprise mode
required: true,
},
payroll: {
type: 'number',
unique: 'true', // Creates a Unique Constraint
},
name: {
type: 'name',
indexed: true, // Creates an Index
},
age: 'number' // Simple schema definition of property : type
});
// Define Multiple Definitions
instance.with({
Movie: require('./models/Movie'),
Person: require('./models/Person')
});
// Load all definitions from a Directory
instance.withDirectory(__dirname+'/models');`
and the error I get is:
`(function (exports, require, module, __filename, __dirname) { import Neode from 'neode';
^^^^^
SyntaxError: Unexpected identifier
at new Script (vm.js:80:7)
at createScript (vm.js:274:10)
at Object.runInThisContext (vm.js:326:10)
at Module._compile (internal/modules/cjs/loader.js:664:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)`
running on node ver 10.15.3
and I just install neode
"dependencies": { "neode": "^0.4.2" }
It looks like you're using ES6 syntax but your version of node doesn't support it. Try using commonjs:
const Neode = require('neode')
or use the babel cli/loaders to run the ES6 code.