Thank you for your prompt response, Jacob.
You're right. Unfortunately, the dump was from a the MATCH clause instead of MERGE clause.
My code with MERGE clause is -
session.writeTransaction(function (transaction) {
transaction.run("merge (u:user{firstName:'" + firstName + "', lastName:'" + lastName + "', email:'" + email + "', githubUrl: '" + githubUrl + "', linkedinUrl:'" + linkedinUrl + "'}) return u");
// var result = transaction.run("match (u:user{firstName: '" + firstName + "'}) return u");
}).then(result => {
console.log("nodes created: ", result.summary.counters.nodesCreated());
}).catch(error => {
console.log('error: ', error)
}).finally(()=>{
session.close();
return res.json({ result });
});
However I'm getting error for summary being undefined. Stack-trace from the error is as given below.
Note that the required node is being added though.
result: Result {
_stack:
'\n at captureStacktrace ( at new Promise (<anonymous>)',
_streamObserver:
_TransactionStreamObserver {
_fieldKeys: null,
_fieldLookup: null,
_queuedRecords: [],
_tail: null,
_error: null,
_hasFailed: false,
_observer: null,
_conn: null,
_meta: {},
_tx:
Transaction {
_connectionHolder: [ConnectionHolder],
_state: [Object],
_onClose: [Function: bound _transactionClosed],
_onBookmark: [Function: bound _updateBookmark] } },
_p: null,
_statement:
'merge (u:user{firstName:\'abc\', lastName:\'dlisnc\', email:\'dvkdsnf\', githubUrl: \'fhsdiukn\', linkedinUrl:\'fsidnfk\'}) return u',
_parameters: {},
_metaSupplier: [Function],
_connectionHolder:
EmptyConnectionHolder {
_mode: undefined,
_connectionProvider: undefined,
_referenceCount: 0,
_connectionPromise: Promise { null } } }
error: TypeError: Cannot read property 'summary' of undefined
at session.writeTransaction.then.result (web-app\server\server.js:69:47)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:20316) UnhandledPromiseRejectionWarning: ReferenceError: result is not defined
at session.writeTransaction.then.catch.finally (web-app\server\server.js:74:27)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:20316) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a
promise which was not handled with .catch(). (rejection id: 1)
(node:20316) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
result: Result {
_stack:
'\n at captureStacktrace at new Promise (<anonymous>)',
_streamObserver:
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:19988) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a
promise which was not handled with .catch(). (rejection id: 1)
(node:19988) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
------------------------------
error: TypeError: Cannot read property 'summary' of undefined
at session.writeTransaction.then.result (web-app\server\server.js:69:47)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:19988) UnhandledPromiseRejectionWarning: ReferenceError: result is not defined
at session.writeTransaction.then.catch.finally (web-app\server\server.js:74:27)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:19988) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a
promise which was not handled with .catch(). (rejection id: 2)
Am I missing something here?