Skip to content

cemremengu/egg-neo4j

Repository files navigation

egg-neo4j

NPM version build status David deps Known Vulnerabilities npm download

Neo4j for egg framework.

Install

$ npm i egg-neo4j --save

Usage

// {app_root}/config/plugin.js
exports.neo4j = {
  enable: true,
  package: 'egg-neo4j',
};

Configuration

// {app_root}/config/config.default.js
exports.neo4j = {
  client: {
    url: 'bolt://127.0.0.1',
    username: 'neo4j',
    password: 'admin',
  },
};

see config/config.default.js for more detail.

Example

Assume that we have User nodes in our database and we want to fetch all of them:

async function all() {
  const session = this.ctx.app.neo4j.session();

  try {
    const result = await session.run('MATCH(user:User) RETURN user');
    return result.records.map((item) => item.get('user').properties);
  } finally {
    session.close();
  }
}

Questions & Suggestions

Please open an issue here.

PRs welcome!

License

MIT

About

Neo4j plugin for egg

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published