|
1 |
| -# AngularNeo4j |
| 1 | +### Use the power of Neo4j graph database in your Angular app |
2 | 2 |
|
3 |
| -This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 6.0.0-rc.6. |
| 3 | +#### Installation |
4 | 4 |
|
5 |
| -## Development server |
| 5 | +To install this library, run: |
6 | 6 |
|
7 |
| -Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. |
| 7 | +```bash |
| 8 | +$ npm install angular-neo4j --save |
| 9 | +``` |
| 10 | +```js |
| 11 | +import { AngularNeo4jModule } from 'angular-neo4j'; |
8 | 12 |
|
9 |
| -## Code scaffolding |
| 13 | +@NgModule({ |
| 14 | + imports: [ |
| 15 | + AngularNeo4jModule |
| 16 | + ] |
| 17 | +}) |
| 18 | +export class AppModule { } |
| 19 | +``` |
10 | 20 |
|
11 |
| -Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. |
| 21 | +### Usage |
| 22 | +The module includes a service and a design-free component utilizing this service: login form and query form. You are welcome to use this component as a foundation for your custom one. |
12 | 23 |
|
13 |
| -## Build |
| 24 | +The fastest way to test everything: |
14 | 25 |
|
15 |
| -Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. |
| 26 | +```html |
| 27 | + <angular-neo4j></angular-neo4j> |
| 28 | +``` |
16 | 29 |
|
17 |
| -## Running unit tests |
| 30 | +Use the service in your own component: |
18 | 31 |
|
19 |
| -Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). |
| 32 | +```javascript |
| 33 | + import { AngularNeo4jService } from './angular-neo4j.service'; |
| 34 | + ... |
| 35 | + constructor(pprivate neo4j: AngularNeo4jService) {} |
| 36 | +``` |
| 37 | +- `connect( url: string, username: string, password: string, encrypted?: boolean )` - Connect to your Neo4j instance |
| 38 | +```javascript |
20 | 39 |
|
21 |
| -## Running end-to-end tests |
| 40 | + const url = 'bolt://localhost:7687'; |
| 41 | + const username = 'neo4j'; |
| 42 | + const password = 'neo4j'; |
| 43 | + const encrypted = true; |
22 | 44 |
|
23 |
| -Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). |
| 45 | + this.neo4j |
| 46 | + .connect( |
| 47 | + url, |
| 48 | + username, |
| 49 | + password, |
| 50 | + encrypted |
| 51 | + ) |
| 52 | + .then(driver => { |
| 53 | + if (driver) { |
| 54 | + console.log(`Successfully connected to ${url}`); |
| 55 | + } |
| 56 | + }); |
| 57 | +``` |
| 58 | +- `run( query: string, params?: object)` - Run the query with parameters. Returns array of records. |
| 59 | +```javascript |
24 | 60 |
|
25 |
| -## Further help |
| 61 | + const query = 'MATCH (n:USER {name: {name}}) RETURN n'; |
| 62 | + const params = { name: 'bob' }; |
26 | 63 |
|
27 |
| -To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). |
| 64 | + this.neo4j.run(query, params).then(res => { |
| 65 | + console.log(res); |
| 66 | + }); |
| 67 | +``` |
| 68 | +- `disconnect()` - Close the active driver |
| 69 | +```javascript |
| 70 | + this.neo4j.disconnect() |
| 71 | +``` |
| 72 | + |
| 73 | +## License |
| 74 | + |
| 75 | +MIT © [Maxim Salnikov ](mailto:[email protected]) |
0 commit comments