简体   繁体   中英

Using Drivine and Neo4j, how can inline a query as a string, rather than injecting a separate file

I'm using Drivine , with Neo4j. The example shows how to inject a query stored in a separate file. How can I simply inline a query as a string?

The idea behind having a separate file is so that queries can be profiled, tested and have a life-cyle in their own right. You don't have to use this if it doesn't suit you.

The example also shows how to create inline queries:

async countAllVertices(): Promise<number> {
    const results = await this.persistenceManager.query<any>(
        new QuerySpecification(`match (n) return count(n) as count`)
    );

    return results[0].count;
}

For simple queries that don't need to be profiled or heavily tested, inline is easier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM