As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
Hi, I am having trouble with one of my user queries. I have an array of user emails, and I want to do a UserQuery for any user that has one of those emails. The sample code for UserQuery shows how to match an individual email:
let userQuery = UserQuery {
$0.email = "james.bond@mi6.com"
}
user.lookup(userQuery) { users, error in
}
Is there a way to do this with something like "$0.email IN <myArrayOfEmails>?
I would rather not have to query each individually if possible.
I am using the Kinvey SDK v 3.3.9, and trying to accomplish this in Swift 3.
Thanks
Best Answer
P
Pranav J
said
about 6 years ago
Nick,
One way to achieve it would be to write a custom endpoint that takes in list of emails to search for:
Below is a sample custom endpoint that can help you start:
// you would need to read the list of emails from your request body and then use it.
function onRequest(request, response, modules) {
var collectionAccess = modules.collectionAccess;
var logger = modules.logger;
var userColl = collectionAccess.collection('user');
var emails = ['abc@gmail.com','def@gmail.com'];
var queryUser = {"email": {"$in": emails}};
userColl.find(queryUser, function (err,users){
logger.info(users);
response.body = users;
response.complete(200);
});
}
I will also confirm with engineering if user discovery supports searching with multiple user email addresses.
To add a bit to this, the query I first tried was this:
let userQuery = UserQuery(format: "email IN %@", myArrayOfEmails)
This is how I would have done the query for any other Entity, but the UserQuery throws an error that it does not support this type of function.
P
Pranav J
said
about 6 years ago
Nick,
If you try the sample code in your case, what results do you get?
let userQuery = UserQuery {
$0.email = "james.bond@mi6.com"
}
user.lookup(userQuery) { users, error in
}
Thanks,
Pranav
Kinvey
N
Nick
said
about 6 years ago
I get a single user, that matches the email set inside the UserQuery brackets. I want to be able to get a list of users, based on a list of input emails. How would I go about doing that in a single query?
N
Nick
said
about 6 years ago
Hi, can anyone help with this issue?
P
Pranav J
said
about 6 years ago
Answer
Nick,
One way to achieve it would be to write a custom endpoint that takes in list of emails to search for:
Below is a sample custom endpoint that can help you start:
// you would need to read the list of emails from your request body and then use it.
function onRequest(request, response, modules) {
var collectionAccess = modules.collectionAccess;
var logger = modules.logger;
var userColl = collectionAccess.collection('user');
var emails = ['abc@gmail.com','def@gmail.com'];
var queryUser = {"email": {"$in": emails}};
userColl.find(queryUser, function (err,users){
logger.info(users);
response.body = users;
response.complete(200);
});
}
I will also confirm with engineering if user discovery supports searching with multiple user email addresses.
Thanks, Pranav Kinvey MLIBZ-1769
N
Nick
said
about 6 years ago
Thanks, the custom endpoint worked as a workaround.
P
Pranav J
said
about 6 years ago
Nick,
Glad to hear that!
Thanks, Pranav Kinvey
P
Pranav J
said
about 6 years ago
Nick,
The feedback from engineering is that User Discovery using multiple email addresses is not supported at this time. Are you fine with using the suggested workaround?
Nick
Hi, I am having trouble with one of my user queries. I have an array of user emails, and I want to do a UserQuery for any user that has one of those emails. The sample code for UserQuery shows how to match an individual email:
Is there a way to do this with something like "$0.email IN <myArrayOfEmails>?
I would rather not have to query each individually if possible.
I am using the Kinvey SDK v 3.3.9, and trying to accomplish this in Swift 3.
Thanks
One way to achieve it would be to write a custom endpoint that takes in list of emails to search for:
Below is a sample custom endpoint that can help you start:
I will also confirm with engineering if user discovery supports searching with multiple user email addresses.
Thanks,
Pranav
Kinvey
MLIBZ-1769
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstNick
To add a bit to this, the query I first tried was this:
let userQuery = UserQuery(format: "email IN %@", myArrayOfEmails)
This is how I would have done the query for any other Entity, but the UserQuery throws an error that it does not support this type of function.
Pranav J
Nick,
If you try the sample code in your case, what results do you get?
Thanks,
Pranav
Kinvey
Nick
I get a single user, that matches the email set inside the UserQuery brackets. I want to be able to get a list of users, based on a list of input emails. How would I go about doing that in a single query?
Nick
Hi, can anyone help with this issue?
Pranav J
One way to achieve it would be to write a custom endpoint that takes in list of emails to search for:
Below is a sample custom endpoint that can help you start:
I will also confirm with engineering if user discovery supports searching with multiple user email addresses.
Thanks,
Pranav
Kinvey
MLIBZ-1769
Nick
Thanks, the custom endpoint worked as a workaround.
Pranav J
Glad to hear that!
Thanks,
Pranav
Kinvey
Pranav J
The feedback from engineering is that User Discovery using multiple email addresses is not supported at this time. Are you fine with using the suggested workaround?
Thanks,
Pranav
Kinvey
Nick
The workaround is good enough for me, thanks.
-
Why do I get "Undefined symbols" errors when building with KinveyKit?
-
How do I register push tokens?
-
When using social login, to perform a log-out, do I need to log out of the social network, Kinvey, o
-
How can I assign additional properties to users?
-
Does KinveyKit support 64-bit ARM devices, such as iPhone 5s?
-
Authorization Token Invalid or Expired
-
BOOL and how it is stored in the database.
-
Offline saving throwing errors
-
Custom endpoint not able to form request object
-
Security through business logic
See all 437 topics