QueryDsl instead of MongoTemplate

68
November 30, 2020, at 10:00 AM

Could you please help me find out how to include the mongo collection name to a QueryDsl query?

Now I can achieve the functionality I want with mongoTemplate like below:

boolean emailExists(String email) {
    Query query = new Query(Criteria.where(Account.EMAIL).is(email));
    return mongoTemplate.count(query, "accountMethod") > 0;      
}

But I want to do something like this:

boolean emailExists(String email) {
    QAccountMethod accountMethod = new QAccountMethod("accountMethod"); //<---Do I need this?
    final BooleanExpression query = QAccount.account.email.eq(email);
    //  return mongoTemplate.count(query, COLLECTION_NAME) > 0;
}

And I guess instead of using

return mongoTemplate.count(query, COLLECTION_NAME) > 0;

use a repository method?

I was thinking something like that? :

boolean existsAccountByEmail(BooleanExpression query, String collectionName);

that results to this:

boolean emailExists(String email) {
    final BooleanExpression query = QAccount.account.email.eq(email);
        //  return mongoTemplate.count(query, COLLECTION_NAME) > 0;
    return accountRepository.existsAccountByEmail(query, COLLECTION_NAME);
}
READ ALSO
Javascript sort an array of strings that containing numbers

Javascript sort an array of strings that containing numbers

I'm trying to sort an array of string that sometimes contain numbers

69
Maxima Segmentation Fault PHP exec() on Ubuntu 20.04

Maxima Segmentation Fault PHP exec() on Ubuntu 20.04

Update: by redirecting stderr from php exec, I can now see that running maxima produces a segmentation fault, increasing the likelihood that this is in fact a bug

66
How to programmatically to capture iOS camera app FROM Android custom app.? (connect via Bluetooth.) [closed]

How to programmatically to capture iOS camera app FROM Android custom app.? (connect via Bluetooth.) [closed]

Want to improve this question? Update the question so it focuses on one problem only by editing this post

77
How to make a button display random images on the slideshow

How to make a button display random images on the slideshow

I have here a simple program that displays random images that are in order, with two buttons that enable you to switch from an ascending order and then descending orderNow, I want to implement a random button that will display a random image of the selection...

24