Schema changed, findMany implemented

This commit is contained in:
j-weissen 2022-09-26 12:32:27 +02:00
parent f3dbc6d59b
commit 3786a803a6
2 changed files with 39 additions and 5 deletions

View file

@ -4,6 +4,38 @@
* note controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
const {createCoreController} = require('@strapi/strapi').factories;
module.exports = createCoreController('api::note.note');
module.exports = createCoreController('api::note.note', ({strapi}) => ({
/**
* Gives all, to the user related, notes.
* @param ctx
* @returns {Promise<string>}
*/
async find(ctx) {
const userId = ctx.state.user.id;
const entries = await strapi.entityService.findMany('api::note.note', {
populate: ['owners'],
filters: {
owners: {
id: userId
}
},
sort: 'lastViewed'
});
return JSON.stringify(entries);
},
/**
* Finds the note by id. Only returns the note when the user is assigned.
* @param ctx
* @returns {Promise<void>}
*/
async findOne(ctx) {
console.log("findOne")
}
}));
/**
*
*/