-
Notifications
You must be signed in to change notification settings - Fork 33
Quick Start
Jasper Blues edited this page Mar 7, 2020
·
9 revisions
npm install @liberation-data/drivine
NEO_DATABASE_TYPE=NEO4J
NEO_DATABASE_USER='neo4j'
NEO_DATABASE_PASSWORD='h4ckM3'
NEO_DATABASE_HOST='localhost'
NEO_DATABASE_PORT='7687'
TRAFFIC_DATABASE_TYPE=AGENS_GRAPH
TRAFFIC_DATABASE_NAME='maps'
TRAFFIC_DATABASE_USER='agens'
TRAFFIC_DATABASE_PASSWORD='h4ckMe'
TRAFFIC_DATABASE_HOST='localhost'
TRAFFIC_DATABASE_PORT='5432'
TRAFFIC_DATABASE_IDLE_TIMEOUT=500
TRAFFIC_DATABASE_DEFAULT_GRAPH_PATH=traffic
You can also define a default connection with no name prefix.
@Module({
imports: [
DrivineModule.withOptions(<DrivineModuleOptions> {
connectionProviders: [
DatabaseRegistry.buildOrResolveFromEnv('NEO')
]
}),
],
providers: [RouteRepository],
controllers: [RouteController],
})
export class AppModule implements NestModule {}
@Injectable()
export class RouteRepository {
constructor(
@InjectPersistenceManager() readonly persistenceManager: PersistenceManager,
@InjectCypher('@/traffic/routesBetween') readonly routesBetween: Statement) {
}
@Transactional() // Has default Propagation.REQUIRED - so partipicate in a current txn, or start one.
async findFastestBetween(start: string, destination: string): Promise<Route> {
return this.persistenceManager.getOne(
new QuerySpecification<Route>()
.withStatement(this.routesBetween)
.bind([start, destination])
.limit(1)
.transform(Route)
);
}
}
Too much work? Clone the starter template and start hacking.
This module contains a basic starter template. Also, so that you can get rolling as quickly as possible, a number a graph database koans, for typical use-cases - recommendations, social networks, etc, each presented in a Drivine style.
Looking for a quick start? Try the sample application | Something not clear? Send us a tweet! | drivine.org