3.3.2 • Published 8 years ago

neo4-js v3.3.2

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

Neo4-js

Build Status dependencies Status devDependencies Status styled with prettier

Neo4-js is a object-graph mapper for JavaScript and neo4j with full TypeScript support. Neo4-js hides repetitive queries such as the basic CRUD operations to the developer. For best development experience use TypeScript to obtain good autocomplete results.

Usage

With neo4-js you are able to quickly define your data model but maintain complete control over your models. The following code snipped shows how you can work with neo4-js.

type PersonProps = {
  name?: StringProperty;
};

type TaskProps = {
  title?: StringProperty;
  done?: boolean;
};

class PersonModel extends Model<PersonProps, PersonInstance> {}
const Person: PersonModel = new PersonModel("Person");

class TaskModel extends Model<TaskProps, TaskInstance> {}
const Task: TaskModel = new TaskModel("Task");

const TaskCreatorRelation = relation
  .from(() => Person)
  .to(() => Task)
  .via("created");

const TaskAssigneeRelation = relation
  .from(Person)
  .to(Task)
  .via("assigned");

@model(Person)
class PersonInstance extends ModelInstance<PersonProps> {
  @hasMany(Task, TaskCreatorRelation)
  tasks: HasManyActions<TaskProps, TaskInstance>;

  @hasMany(Task, TaskAssigneeRelation)
  assignedTasks: HasManyActions<TaskProps, TaskInstance>;
}

@model(Task)
class TaskInstance extends ModelInstance<TaskProps> {
  @hasOne(() => Person, () => TaskCreatorRelation)
  creator: HasOneActions<PersonProps, PersonInstance>;
}

(async () => {
  const paul: PersonInstance = await Person.create({ name: "Paul" });

  const propsArray: TaskProps[] = [
    {
      title: "Buy milk",
    },
    {
      title: "Buy beer",
      done: false,
    },
  ];

  const tasks: TaskInstance[] = await paul.tasks.create(propsArray);
})();

Documentation

The documentation is not completed yet but you'll find the basics on neo4.js.org. Any help is very much appreciated!

Installing

To use neo4-js properly you need to add TypeScript to your project. For now we also install ts-node so that we are able to run our code without compiling it manually before running.

yarn add -D typescript ts-node

I recommend using the following tsconfig.json configuration.

{
  "compilerOptions": {
    "module": "commonjs",
    "moduleResolution": "node",
    "target": "ES6",
    "experimentalDecorators": true,
  }
}

You might also install Docker to quickly create a neo4j database without any further installations. For neo4-js I used the following bash script to start a neo4j instance in docker. To run it you might create a scripts directory and add the following to neo4j-startup.sh, make sure you can execute the script with chmod 777 neo4j-startup.sh (because why not 777 on my local machine :P).

# REST PORT: 10000
# BOLT PORT: 10001
echo "docker run -p 10000:7474 -p 10001:7687 --rm --env=NEO4J_AUTH=none neo4j"
docker run -p 10000:7474 -p 10001:7687 --rm --env=NEO4J_AUTH=none neo4j

The only runtime dependency you need to start using neo4-js is neo4-js itself.

yarn add neo4-js

Built With

  • TypeScript - TypeScript is a typed superset of Javascript that compiles to plain Javascript.

Contributing

Feel free to send a pull request or create an issue for bugs or feature requests.

Authors

  • Jan Schlacher - Initial work

License

This project is licensed under the MIT License - see the LICENSE.md file for details

3.3.2

8 years ago

3.3.1

8 years ago

3.3.0

8 years ago

3.2.2

8 years ago

3.2.1

8 years ago

3.1.1

8 years ago

3.1.0

8 years ago

3.0.4

8 years ago

3.0.3

8 years ago

3.0.2

8 years ago

3.0.1

9 years ago

3.0.1-rc.2

9 years ago

3.0.1-rc.1

9 years ago

3.0.0

9 years ago

2.1.3

9 years ago

2.1.2

9 years ago

2.1.1

9 years ago

2.1.0

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

2.0.0-beta.23

9 years ago

2.0.0-beta.22

9 years ago

2.0.0-beta.21

9 years ago

2.0.0-beta.20

9 years ago

2.0.0-beta.19

9 years ago

2.0.0-beta.18

9 years ago

2.0.0-beta.17

9 years ago

2.0.0-beta.16

9 years ago

2.0.0-beta.15

9 years ago

2.0.0-beta.14

9 years ago

2.0.0-beta.13

9 years ago

2.0.0-beta.11

9 years ago

2.0.0-beta.10

9 years ago

2.0.0-rc.9

9 years ago

2.0.0-rc.8

9 years ago

2.0.0-rc.7

9 years ago

2.0.0-rc.6

9 years ago

2.0.0-rc.5

9 years ago

2.0.0-rc.4

9 years ago

2.0.0-rc.3

9 years ago

2.0.0-rc.2

9 years ago

2.0.0-rc.1

9 years ago

2.0.0-beta

9 years ago

1.0.14

9 years ago

1.0.13

10 years ago

1.0.12

10 years ago

1.0.11

10 years ago

1.0.10

10 years ago

1.0.9

10 years ago

1.0.8

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago