Skip to content

Instantly share code, notes, and snippets.

@danstarns
Created November 17, 2021 14:11
Show Gist options
  • Select an option

  • Save danstarns/aca3b54c96e52b6dc2bcde8e58db3074 to your computer and use it in GitHub Desktop.

Select an option

Save danstarns/aca3b54c96e52b6dc2bcde8e58db3074 to your computer and use it in GitHub Desktop.
neo4j-graphql-aggregate-with-ogm
const { OGM } = require("@neo4j/graphql");
const neo4j = require("neo4j");
const typeDefs = gql`
type Movie {
released: BigInt!
tagline: String
title: String!
## Rest of the Relationships
}
## Rest of the Definitions
`;
const driver = neo4j.driver("neo4j://localhost:7687", neo4j.auth.basic("admin", "password"));
const ogm = new OGM({
typeDefs,
driver,
});
const Movie = ogm.model("Movie");
const aggregation = await Movie.aggregate({
aggregate: {
title: {
shortest: true,
longest: true,
},
},
});
console.log(aggregation);
/*
Logs: {
"title": {
"shortest": "Hoffa",
"longest": "One Flew Over the Cuckoo's Nest"
}
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment