Skip to content

Commit e4fd1e3

Browse files
authored
Merge pull request #3 from vjramirez/master
Modification to get full return when comma separated items are specified
2 parents 596bea0 + b9eed25 commit e4fd1e3

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/lib/src/angular-neo4j.service.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Injectable } from '@angular/core';
1+
import { Injectable } from "@angular/core";
22

3-
import neo4j from 'neo4j-driver/lib/browser/neo4j-web';
3+
import neo4j from "neo4j-driver/lib/browser/neo4j-web";
44

55
@Injectable({
6-
providedIn: 'root'
6+
providedIn: "root"
77
})
88
export class AngularNeo4jService {
99
driver;
@@ -49,7 +49,7 @@ export class AngularNeo4jService {
4949
getDriver() {
5050
if (!this.driver) {
5151
throw new Error(
52-
'A connection has not been made to Neo4j. You will need to run `connect(url, username, password)` before you can get the current driver instance'
52+
"A connection has not been made to Neo4j. You will need to run `connect(url, username, password)` before you can get the current driver instance"
5353
);
5454
}
5555
return this.driver;
@@ -61,7 +61,7 @@ export class AngularNeo4jService {
6161
getSession() {
6262
if (!this.driver) {
6363
throw new Error(
64-
'A connection has not been made to Neo4j. You will need to run `connect(url, username, password)` before you can create a new session'
64+
"A connection has not been made to Neo4j. You will need to run `connect(url, username, password)` before you can create a new session"
6565
);
6666
}
6767

@@ -79,7 +79,11 @@ export class AngularNeo4jService {
7979
session.close();
8080

8181
return results.records.map(record => {
82-
return this.processRecord(record.get(0));
82+
var r = [];
83+
for (var i = 0; i < record.length; i++) {
84+
r[i] = this.processRecord(record.get(i));
85+
}
86+
return r;
8387
});
8488
},
8589
err => {
@@ -90,18 +94,18 @@ export class AngularNeo4jService {
9094
}
9195

9296
private processInteger(integer) {
93-
if (integer.constructor.name === 'Integer') {
97+
if (integer.constructor.name === "Integer") {
9498
return integer.toNumber();
9599
}
96100
return integer;
97101
}
98102

99103
private processRecord(record) {
100-
if (record.constructor.name === 'Integer') {
104+
if (record.constructor.name === "Integer") {
101105
return record.toNumber();
102106
}
103107

104-
if (record.constructor.name === 'Path') {
108+
if (record.constructor.name === "Path") {
105109
record.start.identity = this.processInteger(record.start.identity);
106110
record.end.identity = this.processInteger(record.end.identity);
107111
record.segments = record.segments.map(segment => {
@@ -123,14 +127,14 @@ export class AngularNeo4jService {
123127
return record;
124128
}
125129

126-
if (record.constructor.name === 'Relationship') {
130+
if (record.constructor.name === "Relationship") {
127131
record.identity = this.processInteger(record.identity);
128132
record.start = this.processInteger(record.start);
129133
record.end = this.processInteger(record.end);
130134
return record;
131135
}
132136

133-
if (record.constructor.name === 'Node') {
137+
if (record.constructor.name === "Node") {
134138
record.identity = this.processInteger(record.identity);
135139
return record;
136140
}

0 commit comments

Comments
 (0)