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