@ View ( name = "by_principal_and_id" , map = "function(doc) {emit([doc.principal, doc.id], doc)}" ) public CouchDbConsentDecision findByPrincipalAndId ( final String principal , final long id ) { val view = createQuery ( "by_principal_and_id" ) . key ( ComplexKey . of ( principal , id ) ) . limit ( 1 ) . includeDocs ( true ) ; return db . queryView ( view , CouchDbConsentDecision . class ) . stream ( ) . findFirst ( ) . orElse ( null ) ; }
Find a consent decision by + long + ID and principal name . For CouchDb this ID is randomly generated and the pair should be unique with a very high probability but is not guaranteed . This method is mostly only used by tests .