-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Open
Labels
type:featureNew feature or improvement of existing featureNew feature or improvement of existing feature
Description
New Feature / Enhancement Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
Current Limitation
There is no way to do this currently apart from doing orQueries which seem to be expensive
Feature / Enhancement Description
The containsAny query would do the following:
You want to get all objects whose key would be an array that contains any of the values provided by the array given to the function
Example Use Case
Parse.Object 1 {arr: ["a", "b"]}
Parse.Object 2 {arr: ["b"]}
Parse.Object 3 {arr: ["c", "d"]}
Parse.Object 4 {arr: ["a", "d"]}
Parse.Query().containsAny("arr", ["b", "c"])
The objects matching this query would be: 1, 2, 3
Alternatives / Workarounds
You can use this code made by our good friend ChatGPT but I don't know if it would work well with long arrays:
const Parse = require('parse/node');
// Assuming you have initialized Parse using Parse.initialize()
async function queryObjectsContainedIn(query, key, values) {
const subqueries = bleIds.map((bleId) => {
return query.equalTo(key, values);
});
// Combine subqueries using an "or" query
const combinedQuery = Parse.Query.or(...subqueries);
try {
const results = await combinedQuery.find();
return results;
} catch (error) {
console.error('Error while fetching: ', error);
return [];
}
}
3rd Party References
Metadata
Metadata
Assignees
Labels
type:featureNew feature or improvement of existing featureNew feature or improvement of existing feature