Skip to content
This repository has been archived by the owner on Apr 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #24 from LucianoPAlmeida/v1.0.5
Browse files Browse the repository at this point in the history
V1.0.5
  • Loading branch information
LucianoPAlmeida authored Nov 30, 2018
2 parents 56a04d6 + b7c4f87 commit 13351aa
Show file tree
Hide file tree
Showing 6 changed files with 298 additions and 307 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ sudo: required
env:
- NEO4J_VERSION="3.1.0"


before_install:
- nvm install 6.9.3
- nvm use 6.9.3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Abstract some trivial operations on the Neo4j driver for Nodejs and make the use
[![npm version](https://badge.fury.io/js/ogmneo.svg)](https://badge.fury.io/js/ogmneo)
[![npm](https://img.shields.io/npm/dt/ogmneo.svg)](https://www.npmjs.com/package/ogmneo)
[![MIT](https://img.shields.io/badge/License-MIT-red.svg)](https://opensource.org/licenses/MIT)
[![Travis](https://img.shields.io/travis/LucianoPAlmeida/OGMNeo.svg)](https://travis-ci.org/LucianoPAlmeida/OGMNeo)
[![Travis](https://img.shields.io/travis/LucianoPAlmeida/OGMNeo.svg)](https://travis-ci.org/LucianoPAlmeida/OGMNeo?branch=master)
[![Codecov](https://img.shields.io/codecov/c/github/LucianoPAlmeida/OGMNeo.svg)](https://codecov.io/gh/LucianoPAlmeida/OGMNeo)

## Installation
Expand Down
1 change: 1 addition & 0 deletions lib/ogmneo-cypher.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class OGMNeoCypher {
function isStatement(s) {
return _.isString(s) || s.hasOwnProperty('text');
}

//Private validate statements
function _validateStatements(statements) {
if (isStatement(statements)) {
Expand Down
23 changes: 7 additions & 16 deletions lib/ogmneo-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,7 @@ class OGMNeoNode {
*/

static createOperation(node, label = null) {
let value = _.omitBy(node, _.isUndefined);
OGMNeoObjectParse.parseProperties(value);
let objectString = OGMNeoObjectParse.objectString(value);
let labelCypher = (!_.isEmpty(label) && _.isString(label)) ? `:${label}` : '';
let cypher = `CREATE (n${labelCypher} ${objectString}) RETURN n`;
return OGMNeoOperationBuilder.create()
.cypher(cypher)
.object(value)
.type(OGMNeoOperation.WRITE).then((result) => {
let record = _.first(result.records);
return OGMNeoObjectParse.parseRecordNode(record, 'n');
}).build();
return this._insertOperation('CREATE', node, label);
}


Expand All @@ -72,11 +61,15 @@ class OGMNeoNode {
*/

static mergeOperation(node, label = null) {
return this._insertOperation('MERGE', node, label);
}

static _insertOperation(operation, node, label) {
let value = _.omitBy(node, _.isUndefined);
OGMNeoObjectParse.parseProperties(value);
let objectString = OGMNeoObjectParse.objectString(value);
let labelCypher = (!_.isEmpty(label) && _.isString(label)) ? `:${label}` : '';
let cypher = `MERGE (n${labelCypher} ${objectString}) RETURN n`;
let cypher = `${operation} (n${labelCypher} ${objectString}) RETURN n`;
return OGMNeoOperationBuilder.create()
.cypher(cypher)
.object(value)
Expand All @@ -86,8 +79,6 @@ class OGMNeoNode {
}).build();
}



/**
* Updates a node on neo4j.
*
Expand Down Expand Up @@ -448,7 +439,6 @@ class OGMNeoNode {
}
}


/**
* Operation for find nodes filtered by the query parameter.
*
Expand Down Expand Up @@ -509,6 +499,7 @@ class OGMNeoNode {
throw new Error('A OGMNeoQuery object must to be provided');
}
}

/**
* Adding label to a node.
*
Expand Down
Loading

0 comments on commit 13351aa

Please sign in to comment.