diff --git a/lib-new/GraphDatabase.coffee b/lib-new/GraphDatabase.coffee index 0a9b05b..5f3df4b 100644 --- a/lib-new/GraphDatabase.coffee +++ b/lib-new/GraphDatabase.coffee @@ -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 @@ -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] diff --git a/test-new/cypher._coffee b/test-new/cypher._coffee index 45feacc..12f2afa 100644 --- a/test-new/cypher._coffee +++ b/test-new/cypher._coffee @@ -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: '''