How to use the neo4j-driver.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 neo4j-contrib / neovis.js / __tests__ / neovis.tests.js View on Github external
it('should call sizeCypher and save return value to data set value', async () => {
			const node = testUtils.makeNode([label1]);
			testUtils.mockFullRunSubscribe({
				[initial_cypher]: {
					default: [testUtils.makeRecord([node])]
				},
				[sizeCypher]: {
					[node.identity.toInt()]: [testUtils.makeRecord([Neo4j.int(1)])]
				}
			});

			neovis.render();
			await testUtils.neovisRenderDonePromise(neovis);
			expect(Neo4jMock.mockSessionRun).toHaveBeenCalledTimes(1 + 1); // once for initial cypher and once for the sizeCypher
			expect(neovis._data.nodes.get(1)).toHaveProperty('value', 1);
		});
	});
github neo4j-contrib / neovis.js / src / neovis.js View on Github external
const captionKey = labelConfig && labelConfig['caption'];
		const sizeKey = labelConfig && labelConfig['size'];
		const sizeCypher = labelConfig && labelConfig['sizeCypher'];
		const communityKey = labelConfig && labelConfig['community'];

		node.id = neo4jNode.identity.toInt();

		// node size

		if (sizeCypher) {
			// use a cypher statement to determine the size of the node
			// the cypher statement will be passed a parameter {id} with the value
			// of the internal node id

			let session = this._driver.session();
			const result = await session.run(sizeCypher, {id: Neo4j.int(node.id)});
			for (let record of result.records) {
				record.forEach((v) => {
					if (typeof v === 'number') {
						node.value = v;
					} else if (Neo4j.isInt(v)) {
						node.value = v.toNumber();
					}
				});
			}
		} else if (typeof sizeKey === 'number') {
			node.value = sizeKey;
		} else {
			let sizeProp = neo4jNode.properties[sizeKey];

			if (sizeProp && typeof sizeProp === 'number') {
				// property value is a number, OK to use
github neo4j-contrib / neovis.js / __tests__ / testUtils.js View on Github external
export function makeRelationship(type, startNode, endNode, properties = {}) {
	return new Neo4j.types.Relationship(Neo4j.int(counter++), startNode.identity, endNode.identity, type, properties);
}
github neo4j-contrib / neovis.js / __tests__ / testUtils.js View on Github external
export function makeNode(labels, properties = {}) {
	return new Neo4j.types.Node(Neo4j.int(counter++), labels, properties);
}
github neo4j / neo4j-browser / src / shared / services / bolt / boltMappings.js View on Github external
return new types[className](
          applyGraphTypes(item.hour),
          applyGraphTypes(item.minute),
          applyGraphTypes(item.second),
          applyGraphTypes(item.nanosecond)
        )
      case 'Time':
        return new types[className](
          applyGraphTypes(item.hour),
          applyGraphTypes(item.minute),
          applyGraphTypes(item.second),
          applyGraphTypes(item.nanosecond),
          applyGraphTypes(item.timeZoneOffsetSeconds)
        )
      case 'Integer':
        return neo4j.int(tmpItem)
      default:
        return item
    }
  } else if (typeof rawItem === 'object') {
    let typedObject = {}
    Object.keys(rawItem).forEach(key => {
      typedObject[key] = applyGraphTypes(rawItem[key], types)
    })
    typedObject = unEscapeReservedProps(typedObject, reservedTypePropertyName)
    return typedObject
  } else {
    return rawItem
  }
}
github neo4j-graphql / neo4j-graphql-js / src / translate.js View on Github external
(serialized, [key, value]) => {
          if (Number.isInteger(value)) value = neo4j.int(value);
          serialized[key] = value;
          return serialized;
        },
        {}
github neo4j-graphql / neo4j-graphql-js / src / utils.js View on Github external
Object.keys(neo4jTypeParam).forEach(paramFieldName => {
    const fieldAst = neo4jTypeFields.find(
      field => field.name.value === paramFieldName
    );
    const unwrappedFieldType = unwrapNamedType({ type: fieldAst.type });
    const fieldTypeName = unwrappedFieldType.name;
    if (
      fieldTypeName === GraphQLInt.name &&
      Number.isInteger(neo4jTypeParam[paramFieldName])
    ) {
      const serialized = neo4j.int(neo4jTypeParam[paramFieldName]);
      let param = params[paramName];
      if (paramIndex >= 0) {
        if (paramKey) param = params[paramKey][paramName][paramIndex];
        else param = param[paramIndex];
      } else if (paramKey) param = params[paramKey][paramName];
      param[paramFieldName] = serialized;
    }
  });
  return params;