How to use the neo4j-driver.v1.int 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 Drapegnik / social-graph / api / db.js View on Github external
exports._getRecommendation = function(req, res, next) {
    session.run(
        'MATCH (user:Person {id: {userId}})-[:FRIEND]-(userFriends)-[:FRIEND]-(userFriendsFriends)' +
        'WHERE NOT (user)-[:FRIEND]-(userFriendsFriends)' +
        'RETURN userFriendsFriends.id, userFriendsFriends.name, count(*) AS CommonFriends ORDER BY CommonFriends DESC LIMIT 5',
        {userId: neo4j.int(req.params.userId)}
    ).then(function(results) {
        var response = results.records.map(function(record) {
            return {
                id: record._fields[0],
                name: record._fields[1],
                common: record._fields[2].low
            };
        });
        if (!response[0] || response[0].common < 2) {
            response = [];
        }
        res.send(response);
    }).catch(function(error) {
        console.log(error);
        next(error);
    });
github brikteknologier / seraph / lib / bolt / seraph.js View on Github external
var treatObj = obj => {
      if (typeof obj == 'number') return pr(obj % 1 === 0 ? neo4j.int(obj) : obj);
      else if (obj instanceof Promise) return obj.then(val => treatObj(val));
      else if (neo4j.isInt(obj)) return pr(obj);
      else if (Array.isArray(obj)) return Promise.all(obj.map(treatObj));
      else if (typeof obj == 'object' && obj !== null) 
        return Promise.all(_.map(obj, (v,k) => { return treatObj(v).then(v => [k,v]) }))
          .then(tuples => _.object(tuples))
      else return pr(obj);
    }
    return params ? treatObj(params) : pr(params);
github brikteknologier / seraph / lib / bolt / seraph.js View on Github external
return new Promise((resolve, reject) => {
      if (neo4j.isInt(obj)) return resolve(obj);
      var id;
      if (requireData) {
        id = typeof obj == 'object' ? obj[this.options.id] : undefined;
      } else {
        id = typeof obj == 'object' ? obj[this.options.id] : obj;
      }

      if (id != null) id = parseInt(id, 10);
      if (isNaN(id) || id == null) return reject(new Error("Invalid ID"));
      resolve(neo4j.int(id));
    });
  }
github Edgeryders-Participio / realities / api / src / graphql / types / QueryType.js View on Github external
resolve(object, { id }, { neo4jSession }) {
        return neo4jSession
          .run('MATCH (n) WHERE ID(n)={idParam} RETURN n', { idParam: neo4j.int(id) })
          .then((result) => {
            const singleRecord = result.records[0];
            const person = singleRecord.get(0);
            neo4jSession.close();
            return {
              id,
              name: person.properties.name,
            };
          });
      },
    },