mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 18:33:55 +00:00
Filter undefined results
This commit is contained in:
parent
0074ca6304
commit
f833622e19
@ -21,7 +21,9 @@ module.exports = {
|
||||
// Run queries in parallel.
|
||||
const results = await Promise.all(queries.map((query) => this.makeQuery(model, query)));
|
||||
// Use to match initial queries order.
|
||||
resolve(this.mapData(model, keys, map, results));
|
||||
const data = this.mapData(model, keys, map, results);
|
||||
|
||||
resolve(data);
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
@ -45,9 +47,9 @@ module.exports = {
|
||||
// Extracting ids from original request to map with query results.
|
||||
const ids = query.options.query[ref.primaryKey];
|
||||
|
||||
return ids.map(id =>
|
||||
data.find(entry => (entry._id || entry.id || '').toString() === id.toString())
|
||||
);
|
||||
return ids
|
||||
.map(id => data.find(entry => (entry._id || entry.id || '').toString() === id.toString()))
|
||||
.filter(entry => entry !== undefined);
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@ -439,7 +439,7 @@ module.exports = {
|
||||
}
|
||||
|
||||
return association.model ?
|
||||
resolvers.fetch(params, association.plugin, []):
|
||||
Loaders.loaders[association.collection || association.model].load({ params, options: queryOpts, single: true }):
|
||||
Loaders.loaders[association.collection || association.model].load({ options: queryOpts });
|
||||
|
||||
// const value = await (association.model
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user