Skip to content

Instantly share code, notes, and snippets.

@solancer
Created February 15, 2022 06:26
Show Gist options
  • Select an option

  • Save solancer/7b1a8c7fe374abc1978e63a6623ed4ff to your computer and use it in GitHub Desktop.

Select an option

Save solancer/7b1a8c7fe374abc1978e63a6623ed4ff to your computer and use it in GitHub Desktop.
Replacing findOne in service - strapi
const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::pack.pack', ({ strapi }) => ({
// Method 3: Replacing a core service
async findOne(packId, params = {}) {
const entry = await strapi.db.query('api::pack.pack').findOne({
select: ['label', 'description', 'version'],
where: { packId: packId },
populate: {definitions: true},
});
return entry;
}
})
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment