Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib-new/GraphDatabase.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ module.exports = class GraphDatabase
{query, params, lean} = query

# NOTE: Lowercase 'rest' matters here for parsing.
formats.push format = if lean then 'row' else 'rest'
format = if lean is true then 'row' else (lean or 'rest')
formats.push format

# NOTE: Braces needed by CoffeeLint for now.
# https://github.com/clutchski/coffeelint/issues/459
Expand Down Expand Up @@ -285,8 +286,10 @@ module.exports = class GraphDatabase
# parse nodes & relationships into object instances if this
# query didn't request a raw format. Phew!
$(data).pluck(format).map (row) ->
result = {}
if format is 'graph'
return row

result = {}
for column, j in columns
result[column] = row[j]

Expand Down
18 changes: 18 additions & 0 deletions test-new/cypher._coffee
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,24 @@ describe 'GraphDatabase::cypher', ->
r: TEST_REL.properties
]

it 'should support graph format results', (_) ->
results = DB.cypher
query: '''
START a = node({idA})
MATCH (a) -[r]-> (b)
RETURN a, b, r
'''
params:
idA: TEST_NODE_A._id
lean: 'graph'
, _

expect(results).to.eql [
a: TEST_NODE_A.properties
b: TEST_NODE_B.properties
r: TEST_REL.properties
]

it 'should support simple batching', (_) ->
results = DB.cypher [
query: '''
Expand Down