function BaseBuffer(size) { (0, _classCallCheck3.default)(this, BaseBuffer); this.position = 0; this.length = size; // Calling these out - this is the required // methods a subclass needs to implement var getUInt8 = null; var getInt8 = null; var getFloat64 = null; var getSlice = null; var putFloat64 = null; var putUInt8 = null; var putInt8 = null; }
n/a
function CombinedBuffer(buffers) { (0, _classCallCheck3.default)(this, CombinedBuffer); var length = 0; for (var i = 0; i < buffers.length; i++) { length += buffers[i].length; } var _this3 = (0, _possibleConstructorReturn3.default)(this, (CombinedBuffer.__proto__ || (0, _getPrototypeOf2.default)(CombinedBuffer )).call(this, length)); _this3._buffers = buffers; return _this3; }
...
value: function _onHeader(header) {
if (header == 0) {
// Message boundary
var message = void 0;
if (this._currentMessage.length == 1) {
message = this._currentMessage[0];
} else {
message = new _buf.CombinedBuffer(this._currentMessage);
}
this._currentMessage = [];
this.onmessage(message);
return this.AWAITING_CHUNK;
} else {
this._chunkSize = header;
return this.IN_CHUNK;
...
function HeapBuffer(arg) { (0, _classCallCheck3.default)(this, HeapBuffer); var buffer = arg instanceof ArrayBuffer ? arg : new ArrayBuffer(arg); var _this = (0, _possibleConstructorReturn3.default)(this, (HeapBuffer.__proto__ || (0, _getPrototypeOf2.default)(HeapBuffer)). call(this, buffer.byteLength)); _this._buffer = buffer; _this._view = new DataView(_this._buffer); return _this; }
...
self._pending = null;
for (var i = 0; i < pending.length; i++) {
self.write(pending[i]);
}
};
this._ws.onmessage = function (event) {
if (self.onmessage) {
var b = new _buf.HeapBuffer(event.data);
self.onmessage(b);
}
};
this._ws.onerror = this._handleConnectionError;
}
...
function NodeBuffer(arg) { (0, _classCallCheck3.default)(this, NodeBuffer); var buffer = arg instanceof _node.Buffer ? arg : new _node.Buffer(arg); var _this4 = (0, _possibleConstructorReturn3.default)(this, (NodeBuffer.__proto__ || (0, _getPrototypeOf2.default)(NodeBuffer)). call(this, buffer.length)); _this4._buffer = buffer; return _this4; }
...
this._conn = connect(opts, function () {
if (!self._open) {
return;
}
self._conn.on('data', function (buffer) {
if (self.onmessage) {
self.onmessage(new _buf.NodeBuffer(buffer));
}
});
self._conn.on('error', self._handleConnectionError);
self._conn.on('end', self._handleConnectionTerminated);
// Drain all pending messages
...
function SliceBuffer(start, length, inner) { (0, _classCallCheck3.default)(this, SliceBuffer); var _this2 = (0, _possibleConstructorReturn3.default)(this, (SliceBuffer.__proto__ || (0, _getPrototypeOf2.default)(SliceBuffer )).call(this, length)); _this2._start = start; _this2._inner = inner; return _this2; }
n/a
function alloc(size) { return new _DefaultBuffer(size); }
...
var buffer = require('buffer');
var Buffer = buffer.Buffer;
var SlowBuffer = buffer.SlowBuffer;
var MAX_LEN = buffer.kMaxLength || 2147483647;
exports.alloc = function alloc(size, fill, encoding) {
if (typeof Buffer.alloc === 'function') {
return Buffer.alloc(size, fill, encoding);
}
if (typeof encoding === 'number') {
throw new TypeError('encoding must not be number');
}
if (typeof size !== 'number') {
throw new TypeError('size must be a number');
}
...
function DummyChannel(opts) { (0, _classCallCheck3.default)(this, DummyChannel); this.written = []; }
n/a
function Chunker(channel, bufferSize) { (0, _classCallCheck3.default)(this, Chunker); var _this = (0, _possibleConstructorReturn3.default)(this, (Chunker.__proto__ || (0, _getPrototypeOf2.default)(Chunker)).call( this, 0)); _this._bufferSize = bufferSize || _DEFAULT_BUFFER_SIZE; _this._ch = channel; _this._buffer = (0, _buf.alloc)(_this._bufferSize); _this._currentChunkStart = 0; _this._chunkOpen = false; return _this; }
...
*/
this.url = url;
this.server = { address: url };
this._pendingObservers = [];
this._currentObserver = undefined;
this._ch = channel;
this._dechunker = new _chunking.Dechunker();
this._chunker = new _chunking.Chunker(channel);
this._packer = new _packstream.Packer(this._chunker);
this._unpacker = new _packstream.Unpacker();
this._isHandlingFailure = false;
this._currentFailure = null;
// Set to true on fatal errors, to get this out of session pool.
...
function Dechunker() { (0, _classCallCheck3.default)(this, Dechunker); this._currentMessage = []; this._partialChunkHeader = 0; this._state = this.AWAITING_CHUNK; }
...
* to the next pending observer.
*/
this.url = url;
this.server = { address: url };
this._pendingObservers = [];
this._currentObserver = undefined;
this._ch = channel;
this._dechunker = new _chunking.Dechunker();
this._chunker = new _chunking.Chunker(channel);
this._packer = new _packstream.Packer(this._chunker);
this._unpacker = new _packstream.Unpacker();
this._isHandlingFailure = false;
this._currentFailure = null;
...
function ConnectionHolder(mode, connectionProvider) { (0, _classCallCheck3.default)(this, ConnectionHolder); this._mode = mode; this._connectionProvider = connectionProvider; this._referenceCount = 0; this._connectionPromise = _promise2.default.resolve(null); }
...
this._url = url;
this._userAgent = userAgent;
this._openSessions = {};
this._sessionIdGenerator = 0;
this._token = token;
this._config = config;
this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection
.bind(this), Driver._validateConnection.bind(this), config.connectionPoolSize);
this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this));
}
/**
* Create a new connection instance.
* @return {Connection} new connector-api session instance, a low level session API.
* @access private
...
function DirectConnectionProvider(address, connectionPool, driverOnErrorCallback) { (0, _classCallCheck3.default)(this, DirectConnectionProvider); var _this = (0, _possibleConstructorReturn3.default)(this, (DirectConnectionProvider.__proto__ || (0, _getPrototypeOf2.default )(DirectConnectionProvider)).call(this)); _this._address = address; _this._connectionPool = connectionPool; _this._driverOnErrorCallback = driverOnErrorCallback; return _this; }
...
}
}, {
key: '_createConnectionProvider',
//Extension point
value: function _createConnectionProvider(address, connectionPool, driverOnErrorCallback) {
return new _connectionProviders.DirectConnectionProvider(address, connectionPool,
driverOnErrorCallback);
}
//Extension point
}, {
key: '_createSession',
value: function _createSession(mode, connectionProvider, bookmark, config) {
...
function LoadBalancer(address, connectionPool, driverOnErrorCallback) { (0, _classCallCheck3.default)(this, LoadBalancer); var _this2 = (0, _possibleConstructorReturn3.default)(this, (LoadBalancer.__proto__ || (0, _getPrototypeOf2.default)(LoadBalancer )).call(this)); _this2._seedRouter = address; _this2._routingTable = new _routingTable2.default(new _roundRobinArray2.default([_this2._seedRouter])); _this2._rediscovery = new _rediscovery2.default(); _this2._connectionPool = connectionPool; _this2._driverOnErrorCallback = driverOnErrorCallback; _this2._hostNameResolver = LoadBalancer._createHostNameResolver(); return _this2; }
...
(0, _classCallCheck3.default)(this, RoutingDriver);
return (0, _possibleConstructorReturn3.default)(this, (RoutingDriver.__proto__ || (0, _getPrototypeOf2.default)(RoutingDriver
)).call(this, url, userAgent, token, RoutingDriver._validateConfig(config)));
}
(0, _createClass3.default)(RoutingDriver, [{
key: '_createConnectionProvider',
value: function _createConnectionProvider(address, connectionPool, driverOnErrorCallback) {
return new _connectionProviders.LoadBalancer(address, connectionPool, driverOnErrorCallback
);
}
}, {
key: '_createSession',
value: function _createSession(mode, connectionProvider, bookmark, config) {
var _this2 = this;
return new RoutingSession(mode, connectionProvider, bookmark, config, function (error, conn) {
...
function SingleConnectionProvider(connectionPromise) { (0, _classCallCheck3.default)(this, SingleConnectionProvider); var _this8 = (0, _possibleConstructorReturn3.default)(this, (SingleConnectionProvider.__proto__ || (0, _getPrototypeOf2.default )(SingleConnectionProvider)).call(this)); _this8._connectionPromise = connectionPromise; return _this8; }
n/a
function Connection(channel, url) {
(0, _classCallCheck3.default)(this, Connection);
/**
* An ordered queue of observers, each exchange response (zero or more
* RECORD messages followed by a SUCCESS message) we recieve will be routed
* to the next pending observer.
*/
this.url = url;
this.server = { address: url };
this._pendingObservers = [];
this._currentObserver = undefined;
this._ch = channel;
this._dechunker = new _chunking.Dechunker();
this._chunker = new _chunking.Chunker(channel);
this._packer = new _packstream.Packer(this._chunker);
this._unpacker = new _packstream.Unpacker();
this._isHandlingFailure = false;
this._currentFailure = null;
// Set to true on fatal errors, to get this out of session pool.
this._isBroken = false;
// For deserialization, explain to the unpacker how to unpack nodes, rels, paths;
this._unpacker.structMappers[NODE] = _mappers.node;
this._unpacker.structMappers[RELATIONSHIP] = _mappers.rel;
this._unpacker.structMappers[UNBOUND_RELATIONSHIP] = _mappers.unboundRel;
this._unpacker.structMappers[PATH] = _mappers.path;
var self = this;
// TODO: Using `onmessage` and `onerror` came from the WebSocket API,
// it reads poorly and has several annoying drawbacks. Swap to having
// Channel extend EventEmitter instead, then we can use `on('data',..)`
this._ch.onmessage = function (buf) {
var proposed = buf.readInt32();
if (proposed == 1) {
// Ok, protocol running. Simply forward all messages past
// this to the dechunker
self._ch.onmessage = function (buf) {
self._dechunker.write(buf);
};
if (buf.hasRemaining()) {
self._dechunker.write(buf.readSlice(buf.remaining()));
}
} else if (proposed == 1213486160) {
//server responded 1213486160 == 0x48545450 == "HTTP"
self._handleFatalError((0, _error.newError)("Server responded HTTP. Make sure you are not trying to connect to the http endpoint
" + "(HTTP defaults to port 7474 whereas BOLT defaults to port 7687)"));
} else {
self._handleFatalError((0, _error.newError)("Unknown Bolt protocol version: " + proposed));
}
};
// Listen to connection errors. Important note though;
// In some cases we will get a channel that is already broken (for instance,
// if the user passes invalid configuration options). In this case, onerror
// will have "already triggered" before we add out listener here. So the line
// below also checks that the channel is not already failed. This could be nicely
// encapsulated into Channel if we used `on('error', ..)` rather than `onerror=..`
// as outlined in the comment about `onmessage` further up in this file.
this._ch.onerror = this._handleFatalError.bind(this);
if (this._ch._error) {
this._handleFatalError(this._ch._error);
}
this._dechunker.onmessage = function (buf) {
self._handleMessage(self._unpacker.unpack(buf));
};
var handshake = (0, _buf.alloc)(5 * 4);
//magic preamble
handshake.writeInt32(MAGIC_PREAMBLE);
//proposed versions
handshake.writeInt32(1);
handshake.writeInt32(0);
handshake.writeInt32(0);
handshake.writeInt32(0);
handshake.reset();
this._ch.write(handshake);
}
n/a
function connect(url) { var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var Ch = config.channel || Channel; var host = parseHost(url); var port = parsePort(url) || 7687; var completeUrl = host + ':' + port; return new Connection(new Ch({ host: parseHost(url), port: parsePort(url) || 7687, // Default to using encryption if trust-on-first-use is available encrypted: config.encrypted == null ? (0, _features2.default)("trust_all_certificates") : config.encrypted, // Default to using TRUST_ALL_CERTIFICATES if it is available trust: config.trust || ((0, _features2.default)("trust_all_certificates") ? "TRUST_ALL_CERTIFICATES" : "TRUST_CUSTOM_CA_SIGNED_CERTIFICATES "), trustedCertificates: config.trustedCertificates || [], knownHosts: config.knownHosts }), completeUrl); }
...
return _fs2.default.readFileSync(f);
}),
// Because we manually check for this in the connect callback, to give
// a more helpful error to the user
rejectUnauthorized: false
};
var socket = _tls2.default.connect(opts.port, opts.host, tlsOpts, function () {
if (!socket.authorized) {
onFailure((0, _error.newError)("Server certificate is not trusted. If you trust the database you are connecting to, add
" + " the signing certificate, or the server certificate, to the list of certificates trusted by this driver" +
x22; using `neo4j.v1.driver(.., { trustedCertificates:['path/to/certificate.crt']}). This " + " is a security
measure to protect against man-in-the-middle attacks. If you are just trying " + " Neo4j out and are not concerned about
encryption, simply disable it using `encrypted=\"" + _util.ENCRYPTION_OFF + "\"`" + " in the driver options. Socket responded with: " + socket.authorizationError));
} else {
onSuccess();
}
});
socket.on('error', onFailure);
...
function parseHost(url) { return url.match(URLREGEX)[3]; }
n/a
function parsePort(url) { return url.match(URLREGEX)[4]; }
n/a
function parseScheme(url) { var scheme = url.match(URLREGEX)[1] || ''; return scheme.toLowerCase(); }
n/a
function parseUrl(url) { return url.match(URLREGEX)[2]; }
n/a
function Driver(url, userAgent) { var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; (0, _classCallCheck3.default)(this, Driver); this._url = url; this._userAgent = userAgent; this._openSessions = {}; this._sessionIdGenerator = 0; this._token = token; this._config = config; this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection.bind(this), Driver._validateConnection .bind(this), config.connectionPoolSize); this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this)); }
...
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
(0, _util.assertString)(url, 'Bolt URL');
var scheme = (0, _connector.parseScheme)(url);
if (scheme === "bolt+routing://") {
return new _routingDriver2.default((0, _connector.parseUrl)(url), USER_AGENT, authToken, config);
} else if (scheme === "bolt://") {
return new _driver.Driver((0, _connector.parseUrl)(url), USER_AGENT, authToken, config
);
} else {
throw new Error("Unknown scheme: " + scheme);
}
}
var types = {
Node: _graphTypes.Node,
...
function Driver(url, userAgent) { var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; (0, _classCallCheck3.default)(this, Driver); this._url = url; this._userAgent = userAgent; this._openSessions = {}; this._sessionIdGenerator = 0; this._token = token; this._config = config; this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection.bind(this), Driver._validateConnection .bind(this), config.connectionPoolSize); this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this)); }
...
this._url = url;
this._userAgent = userAgent;
this._openSessions = {};
this._sessionIdGenerator = 0;
this._token = token;
this._config = config;
this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection
.bind(this), Driver._validateConnection.bind(this), config.connectionPoolSize);
this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this));
}
/**
* Create a new connection instance.
* @return {Connection} new connector-api session instance, a low level session API.
* @access private
...
function Neo4jError(message) { var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "N/A"; (0, _classCallCheck3.default)(this, Neo4jError); var _this = (0, _possibleConstructorReturn3.default)(this, (Neo4jError.__proto__ || (0, _getPrototypeOf2.default)(Neo4jError)). call(this, message)); _this.message = message; _this.code = code; return _this; }
n/a
function newError(message) { var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "N/A"; // TODO: Idea is that we can check the code here and throw sub-classes // of Neo4jError as appropriate return new Neo4jError(message, code); }
n/a
function hasFeature(name) { return FEATURES[name] && FEATURES[name](); }
...
this._url = url;
this._userAgent = userAgent;
this._openSessions = {};
this._sessionIdGenerator = 0;
this._token = token;
this._config = config;
this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection
.bind(this), Driver._validateConnection.bind(this), config.connectionPoolSize);
this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this));
}
/**
* Create a new connection instance.
* @return {Connection} new connector-api session instance, a low level session API.
* @access private
...
function GetServersUtil() { (0, _classCallCheck3.default)(this, GetServersUtil); }
...
this._url = url;
this._userAgent = userAgent;
this._openSessions = {};
this._sessionIdGenerator = 0;
this._token = token;
this._config = config;
this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection
.bind(this), Driver._validateConnection.bind(this), config.connectionPoolSize);
this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this));
}
/**
* Create a new connection instance.
* @return {Connection} new connector-api session instance, a low level session API.
* @access private
...
function Node(identity, labels, properties) { (0, _classCallCheck3.default)(this, Node); this.identity = identity; this.labels = labels; this.properties = properties; }
...
onCompleted: NO_OP,
onError: NO_OP
};
/** Maps from packstream structures to Neo4j domain objects */
var _mappers = {
node: function node(unpacker, buf) {
return new _graphTypes.Node(unpacker.unpack(buf), // Identity
unpacker.unpack(buf), // Labels
unpacker.unpack(buf) // Properties
);
},
rel: function rel(unpacker, buf) {
return new _graphTypes.Relationship(unpacker.unpack(buf), // Identity
unpacker.unpack(buf), // Start Node Identity
...
function Path(start, end, segments) { (0, _classCallCheck3.default)(this, Path); this.start = start; this.end = end; this.segments = segments; this.length = segments.length; }
...
rels[-relIndex - 1] = rel = rel.bind(nextNode.identity, prevNode.identity);
}
}
// Done hydrating one path segment.
segments.push(new _graphTypes.PathSegment(prevNode, rel, nextNode));
prevNode = nextNode;
}
return new _graphTypes.Path(nodes[0], nodes[nodes.length - 1], segments);
}
};
/**
* A connection manages sending and recieving messages over a channel. A
* connector is very closely tied to the Bolt protocol, it implements the
* same message structure with very little frills. This means Connectors are
...
function PathSegment(start, rel, end) { (0, _classCallCheck3.default)(this, PathSegment); this.start = start; this.relationship = rel; this.end = end; }
...
rel = rels[-relIndex - 1];
if (rel instanceof _graphTypes.UnboundRelationship) {
// See above
rels[-relIndex - 1] = rel = rel.bind(nextNode.identity, prevNode.identity);
}
}
// Done hydrating one path segment.
segments.push(new _graphTypes.PathSegment(prevNode, rel, nextNode));
prevNode = nextNode;
}
return new _graphTypes.Path(nodes[0], nodes[nodes.length - 1], segments);
}
};
/**
...
function Relationship(identity, start, end, type, properties) { (0, _classCallCheck3.default)(this, Relationship); this.identity = identity; this.start = start; this.end = end; this.type = type; this.properties = properties; }
...
node: function node(unpacker, buf) {
return new _graphTypes.Node(unpacker.unpack(buf), // Identity
unpacker.unpack(buf), // Labels
unpacker.unpack(buf) // Properties
);
},
rel: function rel(unpacker, buf) {
return new _graphTypes.Relationship(unpacker.unpack(buf), // Identity
unpacker.unpack(buf), // Start Node Identity
unpacker.unpack(buf), // End Node Identity
unpacker.unpack(buf), // Type
unpacker.unpack(buf) // Properties
);
},
unboundRel: function unboundRel(unpacker, buf) {
...
function UnboundRelationship(identity, type, properties) { (0, _classCallCheck3.default)(this, UnboundRelationship); this.identity = identity; this.type = type; this.properties = properties; }
...
unpacker.unpack(buf), // Start Node Identity
unpacker.unpack(buf), // End Node Identity
unpacker.unpack(buf), // Type
unpacker.unpack(buf) // Properties
);
},
unboundRel: function unboundRel(unpacker, buf) {
return new _graphTypes.UnboundRelationship(unpacker.unpack(buf), // Identity
unpacker.unpack(buf), // Type
unpacker.unpack(buf) // Properties
);
},
path: function path(unpacker, buf) {
var nodes = unpacker.unpack(buf),
rels = unpacker.unpack(buf),
...
function DnsHostNameResolver() { (0, _classCallCheck3.default)(this, DnsHostNameResolver); var _this2 = (0, _possibleConstructorReturn3.default)(this, (DnsHostNameResolver.__proto__ || (0, _getPrototypeOf2.default)(DnsHostNameResolver )).call(this)); _this2._dns = require('dns'); return _this2; }
...
routingTable.forgetRouter(address);
}
}
}, {
key: '_createHostNameResolver',
value: function _createHostNameResolver() {
if ((0, _features2.default)('dns_lookup')) {
return new _hostNameResolvers.DnsHostNameResolver();
}
return new _hostNameResolvers.DummyHostNameResolver();
}
}]);
return LoadBalancer;
}(ConnectionProvider);
...
function DummyHostNameResolver() { (0, _classCallCheck3.default)(this, DummyHostNameResolver); return (0, _possibleConstructorReturn3.default)(this, (DummyHostNameResolver.__proto__ || (0, _getPrototypeOf2.default)(DummyHostNameResolver )).apply(this, arguments)); }
...
}
}, {
key: '_createHostNameResolver',
value: function _createHostNameResolver() {
if ((0, _features2.default)('dns_lookup')) {
return new _hostNameResolvers.DnsHostNameResolver();
}
return new _hostNameResolvers.DummyHostNameResolver();
}
}]);
return LoadBalancer;
}(ConnectionProvider);
var SingleConnectionProvider = exports.SingleConnectionProvider = function (_ConnectionProvider3) {
(0, _inherits3.default)(SingleConnectionProvider, _ConnectionProvider3);
...
n/a
...
this._url = url;
this._userAgent = userAgent;
this._openSessions = {};
this._sessionIdGenerator = 0;
this._token = token;
this._config = config;
this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection
.bind(this), Driver._validateConnection.bind(this), config.connectionPoolSize);
this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this));
}
/**
* Create a new connection instance.
* @return {Connection} new connector-api session instance, a low level session API.
* @access private
...
inSafeRange = function (val) { return Integer.fromValue(val).inSafeRange(); }
...
### Read integers
Since Integers can be larger than can be represented as JavaScript numbers, it is only safe to convert to JavaScript numbers if
you know that they will not exceed `(2`<sup>`53`</sup>` - 1)` in size.
In order to facilitate working with integers the driver include `neo4j.isInt`, `neo4j.integer.inSafeRange`, `neo4j.integer.toNumber
`, and `neo4j.integer.toString`.
```javascript
var aSmallInteger = neo4j.int(123);
if (neo4j.integer.inSafeRange(aSmallInteger)) {
var aNumber = aSmallInteger.toNumber();
}
```
If you will be handling integers larger than that, you can should convert them to strings:
```javascript
...
int = function (val) { if (val /* is compatible */ instanceof Integer) return val; if (typeof val === 'number') return Integer.fromNumber(val); if (typeof val === 'string') return Integer.fromString(val); // Throws for non-objects, converts non-instanceof Integer: return new Integer(val.low, val.high); }
...
### Write integers
Number written directly e.g. `session.run("CREATE (n:Node {age: {age}})", {age: 22})` will be of type `Float` in Neo4j
.
To write the `age` as an integer the `neo4j.int` method should be used:
```javascript
var neo4j = require('neo4j-driver').v1;
session.run("CREATE (n {age: {myIntParam}})", {myIntParam: neo4j.int(22)});
```
To write integers larger than can be represented as JavaScript numbers, use a string argument to `neo4j.int`:
```javascript
session.run("CREATE (n {age: {myIntParam}})", {myIntParam: neo4j.int("9223372036854775807")});
```
...
isInt = function (obj) { return (obj && obj["__isInteger__"]) === true; }
n/a
toNumber = function (val) { return Integer.fromValue(val).toNumber(); }
...
### Read integers
Since Integers can be larger than can be represented as JavaScript numbers, it is only safe to convert to JavaScript numbers if
you know that they will not exceed `(2`<sup>`53`</sup>` - 1)` in size.
In order to facilitate working with integers the driver include `neo4j.isInt`, `neo4j.integer.inSafeRange`, `neo4j.integer.toNumber
`, and `neo4j.integer.toString`.
```javascript
var aSmallInteger = neo4j.int(123);
if (neo4j.integer.inSafeRange(aSmallInteger)) {
var aNumber = aSmallInteger.toNumber();
}
```
If you will be handling integers larger than that, you can should convert them to strings:
```javascript
var aLargerInteger = neo4j.int("9223372036854775807");
...
toString = function (val, radix) { return Integer.fromValue(val).toString(radix); }
...
neorunPath, '--stop=' + neo4jHome
]);
});
var runScript = function(cmd) {
var spawnSync = childProcess.spawnSync, child, code;
child = spawnSync('python', cmd);
console.log("Script Outputs:\n" + child.stdout.toString());
var error = child.stderr.toString();
if (error.trim() !== "")
console.log("Script Errors:\n"+ error);
code = child.status;
if( code !==0 )
{
throw "Script finished with code " + code
...
function Packer(channel) { (0, _classCallCheck3.default)(this, Packer); this._ch = channel; }
...
this.url = url;
this.server = { address: url };
this._pendingObservers = [];
this._currentObserver = undefined;
this._ch = channel;
this._dechunker = new _chunking.Dechunker();
this._chunker = new _chunking.Chunker(channel);
this._packer = new _packstream.Packer(this._chunker);
this._unpacker = new _packstream.Unpacker();
this._isHandlingFailure = false;
this._currentFailure = null;
// Set to true on fatal errors, to get this out of session pool.
this._isBroken = false;
...
function Structure(signature, fields) { (0, _classCallCheck3.default)(this, Structure); this.signature = signature; this.fields = fields; }
n/a
function Unpacker() { (0, _classCallCheck3.default)(this, Unpacker); // Higher level layers can specify how to map structs to higher-level objects. // If we recieve a struct that has a signature that does not have a mapper, // we simply return a Structure object. this.structMappers = {}; }
...
this.server = { address: url };
this._pendingObservers = [];
this._currentObserver = undefined;
this._ch = channel;
this._dechunker = new _chunking.Dechunker();
this._chunker = new _chunking.Chunker(channel);
this._packer = new _packstream.Packer(this._chunker);
this._unpacker = new _packstream.Unpacker();
this._isHandlingFailure = false;
this._currentFailure = null;
// Set to true on fatal errors, to get this out of session pool.
this._isBroken = false;
...
function Pool(create) { var destroy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () { return true; }; var validate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () { return true; }; var maxIdle = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 50; (0, _classCallCheck3.default)(this, Pool); this._create = create; this._destroy = destroy; this._validate = validate; this._maxIdle = maxIdle; this._pools = {}; this._release = this._release.bind(this); }
...
this._url = url;
this._userAgent = userAgent;
this._openSessions = {};
this._sessionIdGenerator = 0;
this._token = token;
this._config = config;
this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection
.bind(this), Driver._validateConnection.bind(this), config.connectionPoolSize);
this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this));
}
/**
* Create a new connection instance.
* @return {Connection} new connector-api session instance, a low level session API.
* @access private
...
function Record(keys, fields) { var fieldLookup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; (0, _classCallCheck3.default)(this, Record); this.keys = keys; this.length = keys.length; this._fields = fields; this._fieldLookup = fieldLookup || generateFieldLookup(keys); }
...
this._url = url;
this._userAgent = userAgent;
this._openSessions = {};
this._sessionIdGenerator = 0;
this._token = token;
this._config = config;
this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection
.bind(this), Driver._validateConnection.bind(this), config.connectionPoolSize);
this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this));
}
/**
* Create a new connection instance.
* @return {Connection} new connector-api session instance, a low level session API.
* @access private
...
function Rediscovery(getServersUtil) { (0, _classCallCheck3.default)(this, Rediscovery); this._getServersUtil = getServersUtil || new _getServersUtil2.default(); }
...
this._url = url;
this._userAgent = userAgent;
this._openSessions = {};
this._sessionIdGenerator = 0;
this._token = token;
this._config = config;
this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection
.bind(this), Driver._validateConnection.bind(this), config.connectionPoolSize);
this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this));
}
/**
* Create a new connection instance.
* @return {Connection} new connector-api session instance, a low level session API.
* @access private
...
function Result(streamObserver, statement, parameters, metaSupplier, connectionHolder) { (0, _classCallCheck3.default)(this, Result); this._streamObserver = streamObserver; this._p = null; this._statement = statement; this._parameters = parameters || {}; this._metaSupplier = metaSupplier || function () { return {}; }; this._connectionHolder = connectionHolder || _connectionHolder.EMPTY_CONNECTION_HOLDER; }
...
this._url = url;
this._userAgent = userAgent;
this._openSessions = {};
this._sessionIdGenerator = 0;
this._token = token;
this._config = config;
this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection
.bind(this), Driver._validateConnection.bind(this), config.connectionPoolSize);
this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this));
}
/**
* Create a new connection instance.
* @return {Connection} new connector-api session instance, a low level session API.
* @access private
...
function ResultSummary(statement, parameters, metadata) { (0, _classCallCheck3.default)(this, ResultSummary); this.statement = { text: statement, parameters: parameters }; this.statementType = metadata.type; var counters = new StatementStatistics(metadata.stats || {}); this.counters = counters; //for backwards compatibility, remove in future version this.updateStatistics = counters; this.plan = metadata.plan || metadata.profile ? new Plan(metadata.plan || metadata.profile) : false; this.profile = metadata.profile ? new ProfiledPlan(metadata.profile) : false; this.notifications = this._buildNotifications(metadata.notifications); this.server = new ServerInfo(metadata.server); this.resultConsumedAfter = metadata.result_consumed_after; this.resultAvailableAfter = metadata.result_available_after; }
...
this._url = url;
this._userAgent = userAgent;
this._openSessions = {};
this._sessionIdGenerator = 0;
this._token = token;
this._config = config;
this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection
.bind(this), Driver._validateConnection.bind(this), config.connectionPoolSize);
this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this));
}
/**
* Create a new connection instance.
* @return {Connection} new connector-api session instance, a low level session API.
* @access private
...
function RoundRobinArray(items) { (0, _classCallCheck3.default)(this, RoundRobinArray); this._items = items || []; this._offset = 0; }
...
this._url = url;
this._userAgent = userAgent;
this._openSessions = {};
this._sessionIdGenerator = 0;
this._token = token;
this._config = config;
this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection
.bind(this), Driver._validateConnection.bind(this), config.connectionPoolSize);
this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this));
}
/**
* Create a new connection instance.
* @return {Connection} new connector-api session instance, a low level session API.
* @access private
...
function RoutingDriver(url, userAgent) { var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; (0, _classCallCheck3.default)(this, RoutingDriver); return (0, _possibleConstructorReturn3.default)(this, (RoutingDriver.__proto__ || (0, _getPrototypeOf2.default)(RoutingDriver)). call(this, url, userAgent, token, RoutingDriver._validateConfig(config))); }
...
this._url = url;
this._userAgent = userAgent;
this._openSessions = {};
this._sessionIdGenerator = 0;
this._token = token;
this._config = config;
this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection
.bind(this), Driver._validateConnection.bind(this), config.connectionPoolSize);
this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this));
}
/**
* Create a new connection instance.
* @return {Connection} new connector-api session instance, a low level session API.
* @access private
...
function RoutingTable(routers, readers, writers, expirationTime) { (0, _classCallCheck3.default)(this, RoutingTable); this.routers = routers || new _roundRobinArray2.default(); this.readers = readers || new _roundRobinArray2.default(); this.writers = writers || new _roundRobinArray2.default(); this.expirationTime = expirationTime || (0, _integer.int)(0); }
...
this._url = url;
this._userAgent = userAgent;
this._openSessions = {};
this._sessionIdGenerator = 0;
this._token = token;
this._config = config;
this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection
.bind(this), Driver._validateConnection.bind(this), config.connectionPoolSize);
this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this));
}
/**
* Create a new connection instance.
* @return {Connection} new connector-api session instance, a low level session API.
* @access private
...
function Session(mode, connectionProvider, bookmark, config) { (0, _classCallCheck3.default)(this, Session); this._mode = mode; this._readConnectionHolder = new _connectionHolder2.default(_driver.READ, connectionProvider); this._writeConnectionHolder = new _connectionHolder2.default(_driver.WRITE, connectionProvider); this._open = true; this._hasTx = false; this._lastBookmark = bookmark; this._transactionExecutor = _createTransactionExecutor(config); }
...
this._url = url;
this._userAgent = userAgent;
this._openSessions = {};
this._sessionIdGenerator = 0;
this._token = token;
this._config = config;
this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection
.bind(this), Driver._validateConnection.bind(this), config.connectionPoolSize);
this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this));
}
/**
* Create a new connection instance.
* @return {Connection} new connector-api session instance, a low level session API.
* @access private
...
function StreamObserver() { var errorTransformer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (err) { return err; }; (0, _classCallCheck3.default)(this, StreamObserver); this._fieldKeys = null; this._fieldLookup = null; this._queuedRecords = []; this._tail = null; this._error = null; this._hasFailed = false; this._errorTransformer = errorTransformer; this._observer = null; this._conn = null; }
...
this._url = url;
this._userAgent = userAgent;
this._openSessions = {};
this._sessionIdGenerator = 0;
this._token = token;
this._config = config;
this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection
.bind(this), Driver._validateConnection.bind(this), config.connectionPoolSize);
this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this));
}
/**
* Create a new connection instance.
* @return {Connection} new connector-api session instance, a low level session API.
* @access private
...
function Transaction(connectionHolder, onClose, errorTransformer, bookmark, onBookmark) { (0, _classCallCheck3.default)(this, Transaction); this._connectionHolder = connectionHolder; var streamObserver = new _TransactionStreamObserver(this); var params = {}; if (bookmark) { params = { bookmark: bookmark }; } this._connectionHolder.getConnection().then(function (conn) { streamObserver.resolveConnection(conn); conn.run('BEGIN', params, streamObserver); conn.pullAll(streamObserver); }).catch(function (error) { return streamObserver.onError(error); }); this._state = _states.ACTIVE; this._onClose = onClose; this._errorTransformer = errorTransformer; this._onBookmark = onBookmark || function () {}; }
...
this._url = url;
this._userAgent = userAgent;
this._openSessions = {};
this._sessionIdGenerator = 0;
this._token = token;
this._config = config;
this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection
.bind(this), Driver._validateConnection.bind(this), config.connectionPoolSize);
this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this));
}
/**
* Create a new connection instance.
* @return {Connection} new connector-api session instance, a low level session API.
* @access private
...
function TransactionExecutor(maxRetryTimeMs, initialRetryDelayMs, multiplier, jitterFactor) { (0, _classCallCheck3.default)(this, TransactionExecutor); this._maxRetryTimeMs = _valueOrDefault(maxRetryTimeMs, DEFAULT_MAX_RETRY_TIME_MS); this._initialRetryDelayMs = _valueOrDefault(initialRetryDelayMs, DEFAULT_INITIAL_RETRY_DELAY_MS); this._multiplier = _valueOrDefault(multiplier, DEFAULT_RETRY_DELAY_MULTIPLIER); this._jitterFactor = _valueOrDefault(jitterFactor, DEFAULT_RETRY_DELAY_JITTER_FACTOR); this._inFlightTimeoutIds = []; this._verifyAfterConstruction(); }
...
this._url = url;
this._userAgent = userAgent;
this._openSessions = {};
this._sessionIdGenerator = 0;
this._token = token;
this._config = config;
this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection
.bind(this), Driver._validateConnection.bind(this), config.connectionPoolSize);
this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this));
}
/**
* Create a new connection instance.
* @return {Connection} new connector-api session instance, a low level session API.
* @access private
...
function assertString(obj, objName) { if (!isString(obj)) { throw new TypeError(objName + ' expected to be string but was: ' + (0, _stringify2.default)(obj)); } return obj; }
n/a
function isEmptyObjectOrNull(obj) { if (isNull(obj)) { return true; } if (!isObject(obj)) { return false; } for (var prop in obj) { if (obj.hasOwnProperty(prop)) { return false; } } return true; }
n/a
function Neo4jError(message) { var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "N/A"; (0, _classCallCheck3.default)(this, Neo4jError); var _this = (0, _possibleConstructorReturn3.default)(this, (Neo4jError.__proto__ || (0, _getPrototypeOf2.default)(Neo4jError)). call(this, message)); _this.message = message; _this.code = code; return _this; }
n/a
function driver(url, authToken) { var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; (0, _util.assertString)(url, 'Bolt URL'); var scheme = (0, _connector.parseScheme)(url); if (scheme === "bolt+routing://") { return new _routingDriver2.default((0, _connector.parseUrl)(url), USER_AGENT, authToken, config); } else if (scheme === "bolt://") { return new _driver.Driver((0, _connector.parseUrl)(url), USER_AGENT, authToken, config); } else { throw new Error("Unknown scheme: " + scheme); } }
...
```html
<script src="lib/browser/neo4j-web.min.js"></script>
```
This will make a global `neo4j` object available, where you can access the `v1` API at `neo4j.v1`:
```javascript
var driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j
x22;, "neo4j"));
```
It is not required to explicitly close the driver on a web page. Web browser should gracefully close all open
WebSockets when the page is unloaded. However, driver instance should be explicitly closed when it's lifetime
is not the same as the lifetime of the web page:
```javascript
...
int = function (val) { if (val /* is compatible */ instanceof Integer) return val; if (typeof val === 'number') return Integer.fromNumber(val); if (typeof val === 'string') return Integer.fromString(val); // Throws for non-objects, converts non-instanceof Integer: return new Integer(val.low, val.high); }
...
### Write integers
Number written directly e.g. `session.run("CREATE (n:Node {age: {age}})", {age: 22})` will be of type `Float` in Neo4j
.
To write the `age` as an integer the `neo4j.int` method should be used:
```javascript
var neo4j = require('neo4j-driver').v1;
session.run("CREATE (n {age: {myIntParam}})", {myIntParam: neo4j.int(22)});
```
To write integers larger than can be represented as JavaScript numbers, use a string argument to `neo4j.int`:
```javascript
session.run("CREATE (n {age: {myIntParam}})", {myIntParam: neo4j.int("9223372036854775807")});
```
...
isInt = function (obj) { return (obj && obj["__isInteger__"]) === true; }
n/a
function basic(username, password) { var realm = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; if (realm) { return { scheme: "basic", principal: username, credentials: password, realm: realm }; } else { return { scheme: "basic", principal: username, credentials: password }; } }
...
```html
<script src="lib/browser/neo4j-web.min.js"></script>
```
This will make a global `neo4j` object available, where you can access the `v1` API at `neo4j.v1`:
```javascript
var driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j
x22;, "neo4j"));
```
It is not required to explicitly close the driver on a web page. Web browser should gracefully close all open
WebSockets when the page is unloaded. However, driver instance should be explicitly closed when it's lifetime
is not the same as the lifetime of the web page:
```javascript
...
function custom(principal, credentials, realm, scheme) { var parameters = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined; if (parameters) { return { scheme: scheme, principal: principal, credentials: credentials, realm: realm, parameters: parameters }; } else { return { scheme: scheme, principal: principal, credentials: credentials, realm: realm }; } }
n/a
function Neo4jError(message) { var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "N/A"; (0, _classCallCheck3.default)(this, Neo4jError); var _this = (0, _possibleConstructorReturn3.default)(this, (Neo4jError.__proto__ || (0, _getPrototypeOf2.default)(Neo4jError)). call(this, message)); _this.message = message; _this.code = code; return _this; }
n/a
function driver(url, authToken) { var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; (0, _util.assertString)(url, 'Bolt URL'); var scheme = (0, _connector.parseScheme)(url); if (scheme === "bolt+routing://") { return new _routingDriver2.default((0, _connector.parseUrl)(url), USER_AGENT, authToken, config); } else if (scheme === "bolt://") { return new _driver.Driver((0, _connector.parseUrl)(url), USER_AGENT, authToken, config); } else { throw new Error("Unknown scheme: " + scheme); } }
...
```html
<script src="lib/browser/neo4j-web.min.js"></script>
```
This will make a global `neo4j` object available, where you can access the `v1` API at `neo4j.v1`:
```javascript
var driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j
x22;, "neo4j"));
```
It is not required to explicitly close the driver on a web page. Web browser should gracefully close all open
WebSockets when the page is unloaded. However, driver instance should be explicitly closed when it's lifetime
is not the same as the lifetime of the web page:
```javascript
...
int = function (val) { if (val /* is compatible */ instanceof Integer) return val; if (typeof val === 'number') return Integer.fromNumber(val); if (typeof val === 'string') return Integer.fromString(val); // Throws for non-objects, converts non-instanceof Integer: return new Integer(val.low, val.high); }
...
### Write integers
Number written directly e.g. `session.run("CREATE (n:Node {age: {age}})", {age: 22})` will be of type `Float` in Neo4j
.
To write the `age` as an integer the `neo4j.int` method should be used:
```javascript
var neo4j = require('neo4j-driver').v1;
session.run("CREATE (n {age: {myIntParam}})", {myIntParam: neo4j.int(22)});
```
To write integers larger than can be represented as JavaScript numbers, use a string argument to `neo4j.int`:
```javascript
session.run("CREATE (n {age: {myIntParam}})", {myIntParam: neo4j.int("9223372036854775807")});
```
...
isInt = function (obj) { return (obj && obj["__isInteger__"]) === true; }
n/a
inSafeRange = function (val) { return Integer.fromValue(val).inSafeRange(); }
...
### Read integers
Since Integers can be larger than can be represented as JavaScript numbers, it is only safe to convert to JavaScript numbers if
you know that they will not exceed `(2`<sup>`53`</sup>` - 1)` in size.
In order to facilitate working with integers the driver include `neo4j.isInt`, `neo4j.integer.inSafeRange`, `neo4j.integer.toNumber
`, and `neo4j.integer.toString`.
```javascript
var aSmallInteger = neo4j.int(123);
if (neo4j.integer.inSafeRange(aSmallInteger)) {
var aNumber = aSmallInteger.toNumber();
}
```
If you will be handling integers larger than that, you can should convert them to strings:
```javascript
...
toNumber = function (val) { return Integer.fromValue(val).toNumber(); }
...
### Read integers
Since Integers can be larger than can be represented as JavaScript numbers, it is only safe to convert to JavaScript numbers if
you know that they will not exceed `(2`<sup>`53`</sup>` - 1)` in size.
In order to facilitate working with integers the driver include `neo4j.isInt`, `neo4j.integer.inSafeRange`, `neo4j.integer.toNumber
`, and `neo4j.integer.toString`.
```javascript
var aSmallInteger = neo4j.int(123);
if (neo4j.integer.inSafeRange(aSmallInteger)) {
var aNumber = aSmallInteger.toNumber();
}
```
If you will be handling integers larger than that, you can should convert them to strings:
```javascript
var aLargerInteger = neo4j.int("9223372036854775807");
...
toString = function (val, radix) { return Integer.fromValue(val).toString(radix); }
...
neorunPath, '--stop=' + neo4jHome
]);
});
var runScript = function(cmd) {
var spawnSync = childProcess.spawnSync, child, code;
child = spawnSync('python', cmd);
console.log("Script Outputs:\n" + child.stdout.toString());
var error = child.stderr.toString();
if (error.trim() !== "")
console.log("Script Errors:\n"+ error);
code = child.status;
if( code !==0 )
{
throw "Script finished with code " + code
...
function Node(identity, labels, properties) { (0, _classCallCheck3.default)(this, Node); this.identity = identity; this.labels = labels; this.properties = properties; }
...
onCompleted: NO_OP,
onError: NO_OP
};
/** Maps from packstream structures to Neo4j domain objects */
var _mappers = {
node: function node(unpacker, buf) {
return new _graphTypes.Node(unpacker.unpack(buf), // Identity
unpacker.unpack(buf), // Labels
unpacker.unpack(buf) // Properties
);
},
rel: function rel(unpacker, buf) {
return new _graphTypes.Relationship(unpacker.unpack(buf), // Identity
unpacker.unpack(buf), // Start Node Identity
...
function Path(start, end, segments) { (0, _classCallCheck3.default)(this, Path); this.start = start; this.end = end; this.segments = segments; this.length = segments.length; }
...
rels[-relIndex - 1] = rel = rel.bind(nextNode.identity, prevNode.identity);
}
}
// Done hydrating one path segment.
segments.push(new _graphTypes.PathSegment(prevNode, rel, nextNode));
prevNode = nextNode;
}
return new _graphTypes.Path(nodes[0], nodes[nodes.length - 1], segments);
}
};
/**
* A connection manages sending and recieving messages over a channel. A
* connector is very closely tied to the Bolt protocol, it implements the
* same message structure with very little frills. This means Connectors are
...
function PathSegment(start, rel, end) { (0, _classCallCheck3.default)(this, PathSegment); this.start = start; this.relationship = rel; this.end = end; }
...
rel = rels[-relIndex - 1];
if (rel instanceof _graphTypes.UnboundRelationship) {
// See above
rels[-relIndex - 1] = rel = rel.bind(nextNode.identity, prevNode.identity);
}
}
// Done hydrating one path segment.
segments.push(new _graphTypes.PathSegment(prevNode, rel, nextNode));
prevNode = nextNode;
}
return new _graphTypes.Path(nodes[0], nodes[nodes.length - 1], segments);
}
};
/**
...
function Record(keys, fields) { var fieldLookup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; (0, _classCallCheck3.default)(this, Record); this.keys = keys; this.length = keys.length; this._fields = fields; this._fieldLookup = fieldLookup || generateFieldLookup(keys); }
n/a
function Relationship(identity, start, end, type, properties) { (0, _classCallCheck3.default)(this, Relationship); this.identity = identity; this.start = start; this.end = end; this.type = type; this.properties = properties; }
...
node: function node(unpacker, buf) {
return new _graphTypes.Node(unpacker.unpack(buf), // Identity
unpacker.unpack(buf), // Labels
unpacker.unpack(buf) // Properties
);
},
rel: function rel(unpacker, buf) {
return new _graphTypes.Relationship(unpacker.unpack(buf), // Identity
unpacker.unpack(buf), // Start Node Identity
unpacker.unpack(buf), // End Node Identity
unpacker.unpack(buf), // Type
unpacker.unpack(buf) // Properties
);
},
unboundRel: function unboundRel(unpacker, buf) {
...
function Result(streamObserver, statement, parameters, metaSupplier, connectionHolder) { (0, _classCallCheck3.default)(this, Result); this._streamObserver = streamObserver; this._p = null; this._statement = statement; this._parameters = parameters || {}; this._metaSupplier = metaSupplier || function () { return {}; }; this._connectionHolder = connectionHolder || _connectionHolder.EMPTY_CONNECTION_HOLDER; }
n/a
function ResultSummary(statement, parameters, metadata) { (0, _classCallCheck3.default)(this, ResultSummary); this.statement = { text: statement, parameters: parameters }; this.statementType = metadata.type; var counters = new StatementStatistics(metadata.stats || {}); this.counters = counters; //for backwards compatibility, remove in future version this.updateStatistics = counters; this.plan = metadata.plan || metadata.profile ? new Plan(metadata.plan || metadata.profile) : false; this.profile = metadata.profile ? new ProfiledPlan(metadata.profile) : false; this.notifications = this._buildNotifications(metadata.notifications); this.server = new ServerInfo(metadata.server); this.resultConsumedAfter = metadata.result_consumed_after; this.resultAvailableAfter = metadata.result_available_after; }
n/a
function UnboundRelationship(identity, type, properties) { (0, _classCallCheck3.default)(this, UnboundRelationship); this.identity = identity; this.type = type; this.properties = properties; }
...
unpacker.unpack(buf), // Start Node Identity
unpacker.unpack(buf), // End Node Identity
unpacker.unpack(buf), // Type
unpacker.unpack(buf) // Properties
);
},
unboundRel: function unboundRel(unpacker, buf) {
return new _graphTypes.UnboundRelationship(unpacker.unpack(buf), // Identity
unpacker.unpack(buf), // Type
unpacker.unpack(buf) // Properties
);
},
path: function path(unpacker, buf) {
var nodes = unpacker.unpack(buf),
rels = unpacker.unpack(buf),
...