我正在使用couchbase3和 spring-data-couchbase ,并希望使用具有多列的spring数据库来查询数据 .
public interface UserAccountRepository extends CrudRepository<UserAccount, Long> {
public UserAccount findByEmail(Query eMail);
public UserAccount findByEmailAndStatus(Query query); // fn with multiple column, but not getting the result
}
我应该如何编写Map函数和Reduce函数呢?
为了使函数 findByEmail(Query eMail); 起作用,我添加了带有Map fn()的视图
function (doc, meta) {
emit(doc.email,doc);
}
此视图将电子邮件作为密钥,值为文档 . 但是,如果我需要使用电子邮件和状态查询?视图应该如何?
我看过这个链接,但不是很清楚 . https://stackoverflow.com/questions/28938755
2 回答
你可以在这里的文档中使用复合键,如describe:http://docs.couchbase.com/developer/dev-guide-3.0/compound-keys.html
我能够使springdata函数调用复合Key视图 . 我的文档名称是:Data Compound Key View
SpringData Repository Inferface shown below :
Test Class shown below :
如果这对你有用,请投票