You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Jasper Blues edited this page Feb 24, 2020
·
3 revisions
Repositories are a common pattern of structuring object-oriented code, in order to adhere to single responsibility principle (SRP). They logically group database operations for a particular type of entity.
Simply by using composition, the PersistenceManager can be used to implement repositories. Here is an example:
@Injectable()exportclassHealthRepository{constructor(@InjectPersistenceManager()readonlypersistenceManager: NonTransactionalPersistenceManager){}asynccountAllVertices(): Promise<number>{returnthis.persistenceManager.getOne<number>(newQuerySpecification(`match (n) return count(n) as count`).map((it)=>it.count););}}