1.0.0-next.15 • Published 2 months ago

@neo4j/graph-schema-utils v1.0.0-next.15

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 months ago

Consume

Install for consumption

npm install @neo4j/graph-schema-utils

Use

Validate

This function is needed to perform a validation on a graph schema. The validateSchema function compares the output against the JSON schema.

import { validateSchema } from "@neo4j/graph-schema-utils";

validateSchema(jsonSchema, graphSchema);

Model

You can also create a schema model programatically. Example:

import { model } from "@neo4j/graph-schema-utils";

const labels = [
  new model.NodeLabel("l1", "Person"),
  new model.NodeLabel("l1", "Movie"),
];

const relationshipTypes = [new model.RelationshipType("rt1", "ACTED_IN")];

const properties = [
  new model.Property("name", new model.PropertyBaseType("string"), true),
  new model.Property("title", new model.PropertyBaseType("string"), true),
  new model.Property(
    "roles",
    new model.PropertyArrayType(new model.PropertyBaseType("string")),
    false
  ),
];

const nodeObjectTypes = [
  new model.NodeObjectType("n1", [labels[0]], [properties[0]]), // (:Person {name}) node type
  new model.NodeObjectType("n2", [labels[1]], [properties[1]]), // (:Movie {title}) node type
];

const relationshipObjectTypes = [
  // (:Person {name})-[:ACTED_IN {roles}]->(:Movie {title})
  new model.RelationshipObjectType(
    "r1",
    relationshipTypes[0],
    nodeObjectTypes[0],
    nodeObjectTypes[1],
    [properties[2]]
  ),
];

const graphSchema = new model.GraphSchema(
  nodeObjectTypes,
  relationshipObjectTypes
);

Develop / Contribute

Install dependencies

npm install

Run script

npm start
# or
node ./src/index.js
1.0.0-next.15

2 months ago

1.0.0-next.14

4 months ago

1.0.0-next.13

5 months ago

1.0.0-next.12

5 months ago

1.0.0-next.11

5 months ago

1.0.0-next.10

5 months ago

1.0.0-next.6

1 year ago

1.0.0-next.7

1 year ago

1.0.0-next.8

1 year ago

1.0.0-next.9

1 year ago

1.0.0-next.5

1 year ago

1.0.0-next.4

1 year ago

1.0.0-next.3

1 year ago

1.0.0-next.2

1 year ago

1.0.0-next.1

1 year ago

1.0.0-next.0

1 year ago