mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 19:36:20 +00:00
Add select for findOne method
This commit is contained in:
parent
ab4416c2b2
commit
53518623e4
@ -20,8 +20,14 @@ module.exports = function findOne(_ctx) {
|
||||
// Locate and validate the required `id` parameter.
|
||||
const pk = actionUtil.requirePk(_ctx);
|
||||
|
||||
// Build criteria object
|
||||
const criteria = {};
|
||||
criteria[Model.primaryKey] = pk;
|
||||
|
||||
_.merge(criteria, actionUtil.parseSelect(_ctx));
|
||||
|
||||
// Init the query.
|
||||
let query = Model.findOne(pk);
|
||||
let query = Model.findOne(criteria);
|
||||
query = actionUtil.populateEach(query, _ctx, Model);
|
||||
query.exec(function found(err, matchingRecord) {
|
||||
if (err) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user