How to use the neo4j-driver.v1.types function in neo4j-driver

To help you get started, we’ve selected a few neo4j-driver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github codex-digital / cypher-stream / util / to-native.js View on Github external
var is            = R.is;
var isArrayLike   = R.isArrayLike;
var isNil         = R.isNil;
var map           = R.map;
var mapObjIndexed = R.mapObjIndexed;
var prop          = R.prop;
var zipObj        = R.zipObj;

var recordToNative = converge(zipObj, [prop('keys'), prop('_fields')]);
var isRecord       = both(has('_fields'), has('keys'));

// Recursively map Neo4j values
// to their native equivalants
var toNative = cond([
  [isNil,                        identity],
  [is(neo4j.types.Node),         x => compose(toNative, prop('properties'))(x)],
  [is(neo4j.types.Relationship), prop('properties')],
  [neo4j.isInt,                  invoker(0, 'toInt')],
  [isArrayLike,                  x => map(toNative, x)],
  [isRecord,                     x => compose(toNative, recordToNative)(x)],
  [is(Object),                   x => mapObjIndexed(toNative, x)],
  [R.T,                          identity],
]);

module.exports = toNative;
github codex-digital / cypher-stream / util / to-native.js View on Github external
var isArrayLike   = R.isArrayLike;
var isNil         = R.isNil;
var map           = R.map;
var mapObjIndexed = R.mapObjIndexed;
var prop          = R.prop;
var zipObj        = R.zipObj;

var recordToNative = converge(zipObj, [prop('keys'), prop('_fields')]);
var isRecord       = both(has('_fields'), has('keys'));

// Recursively map Neo4j values
// to their native equivalants
var toNative = cond([
  [isNil,                        identity],
  [is(neo4j.types.Node),         x => compose(toNative, prop('properties'))(x)],
  [is(neo4j.types.Relationship), prop('properties')],
  [neo4j.isInt,                  invoker(0, 'toInt')],
  [isArrayLike,                  x => map(toNative, x)],
  [isRecord,                     x => compose(toNative, recordToNative)(x)],
  [is(Object),                   x => mapObjIndexed(toNative, x)],
  [R.T,                          identity],
]);

module.exports = toNative;
github brikteknologier / seraph / lib / bolt / seraph.js View on Github external
else if (neo4j.isInt(field)) return this._unboxInt(field);
      else if (field instanceof neo4j.types.Node) {
        var obj = field.properties;
        if (this.options.label) obj.labels = field.labels;
        obj[this.options.id] = this._unboxInt(field.identity);
        return this._unboxAll(obj);
      }
      else if (field instanceof neo4j.types.Relationship) {
        field.start = this._unboxInt(field.start);
        field.end = this._unboxInt(field.end);
        field[this.options.id] = this._unboxInt(field.identity);
        if (this.options.id != 'identity') delete field.identity;
        field.properties = this._unboxAll(field.properties);
        return field;
      }
      else if (field instanceof neo4j.types.UnboundRelationship ||
               field instanceof neo4j.types.PathSegment ||
               field instanceof neo4j.types.Path) {
        // no processing for these types yet.
        return field;
      }
      else {
        return _.reduce(field, (obj, val, key) => {
          obj[key] = assemble(val);
          return obj;
        }, {});
      }
    }
    var processed = records.map((record) => {
github Jabher / agregate / agregate / connection / driver / driver.js View on Github external
rehydrate(value: any): any {
    if (Array.isArray(value)) {
      // noinspection JSUnresolvedFunction
      return value.map(entry => this.rehydrate(entry))
    }
    if (value instanceof neo4j.types.Node) {
      return this.rehydrateNode(value)
    }
    if (value instanceof neo4j.types.Relationship) {
      return this.rehydrateRelation(value)
    }
    if (neo4j.isInt(value)) {
      // noinspection JSUnresolvedFunction
      return value.toNumber()
    }
    return value
  }
github Jabher / agregate / agregate / connection / driver / driver.js View on Github external
rehydrate(value: any): any {
    if (Array.isArray(value)) {
      // noinspection JSUnresolvedFunction
      return value.map(entry => this.rehydrate(entry))
    }
    if (value instanceof neo4j.types.Node) {
      return this.rehydrateNode(value)
    }
    if (value instanceof neo4j.types.Relationship) {
      return this.rehydrateRelation(value)
    }
    if (neo4j.isInt(value)) {
      // noinspection JSUnresolvedFunction
      return value.toNumber()
    }
    return value
  }
github brikteknologier / seraph / lib / bolt / seraph.js View on Github external
var assemble = (field) => {
      if (Array.isArray(field)) return field.map(assemble);
      else if (typeof field != 'object' || !field) return field;
      else if (neo4j.isInt(field)) return this._unboxInt(field);
      else if (field instanceof neo4j.types.Node) {
        var obj = field.properties;
        if (this.options.label) obj.labels = field.labels;
        obj[this.options.id] = this._unboxInt(field.identity);
        return this._unboxAll(obj);
      }
      else if (field instanceof neo4j.types.Relationship) {
        field.start = this._unboxInt(field.start);
        field.end = this._unboxInt(field.end);
        field[this.options.id] = this._unboxInt(field.identity);
        if (this.options.id != 'identity') delete field.identity;
        field.properties = this._unboxAll(field.properties);
        return field;
      }
      else if (field instanceof neo4j.types.UnboundRelationship ||
               field instanceof neo4j.types.PathSegment ||
               field instanceof neo4j.types.Path) {