Skip to content

Commit d9589f1

Browse files
committed
Merge pull request #101 from neo-technology/1.1-merge-schema-proc
Reduce number of queries to a single one for :schema
2 parents 9c6599d + 9805102 commit d9589f1

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

app/scripts/services/Bolt.coffee

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,15 @@ angular.module('neo4jApp.services')
198198
else
199199
indexString = "Indexes"
200200
for index in indexes
201-
indexString += "\n #{index.get('description').replace('INDEX','')} #{index.get('state').toUpperCase()}"
202-
if index.get("type") == "node_unique_property"
201+
indexString += "\n #{index.description.replace('INDEX','')} #{index.state.toUpperCase()}"
202+
if index.type == "node_unique_property"
203203
indexString += " (for uniqueness constraint)"
204204
if (constraints.length == 0)
205205
constraintsString = "No constraints"
206206
else
207207
constraintsString = "Constraints"
208208
for constraint in constraints
209-
constraintsString += "\n #{constraint.get('description').replace('CONSTRAINT','')}"
209+
constraintsString += "\n #{constraint.description.replace('CONSTRAINT','')}"
210210
return "#{indexString}\n\n#{constraintsString}\n"
211211

212212
boltResultToRESTResult = (result) ->

app/scripts/services/UtilityBolt.coffee

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,18 @@ angular.module('neo4jApp.services')
3131
clearConnection: -> Bolt.clearConnection()
3232
getSchema: ->
3333
q = $q.defer()
34-
$q.all([
35-
Bolt.callProcedure("db.indexes"),
36-
Bolt.callProcedure("db.constraints"),
37-
]).then((data) ->
38-
q.resolve(Bolt.constructSchemaResult data[0], data[1])
39-
)
34+
Bolt.boltTransaction(
35+
"CALL db.indexes() YIELD description, state, type " +
36+
"WITH COLLECT({description: description, state: state, type: type}) AS indexes " +
37+
"RETURN 'indexes' AS name, indexes AS items " +
38+
"UNION " +
39+
"CALL db.constraints() YIELD description " +
40+
"WITH COLLECT({description: description}) AS constraints " +
41+
"RETURN 'constraints' AS name, constraints AS items"
42+
).promise.then((result) ->
43+
return q.resolve(Bolt.constructSchemaResult([], [])) unless result.records.length
44+
q.resolve(Bolt.constructSchemaResult result.records[0].get('items'), result.records[1].get('items'))
45+
).catch( (e) -> q.reject Bolt.constructResult e)
4046
q.promise
4147

4248
getMeta: ->

0 commit comments

Comments
 (0)