System Information
- Strapi Version: 4.0.6
- Operating System: Mac OS
- Database: postgres/sqlite
- Node Version: 8.3.2
- NPM Version: 16.13.2
- Yarn Version: 1.22.17
I used to have a ‘Is Owner’ policy which worked like a charm. Since the new Strapi v4 update it stopped working…
I highly think this code is outdated because it cannot find the function ‘strapi.query’…
module.exports = {
async find(ctx) {
const { user } = await ctx.state;
const entities = strapi.query("connection").find({ links: user.id });
return entities;
},
}; // BIND LINK TO USER
also my controllers/connections.js which works below, the problem is the code above!
const { createCoreRouter } = require("@strapi/strapi").factories;
module.exports = createCoreRouter("api::connection.connection", {
config: {
create: {
policies: [
// pass a policy implementation directly
(policyContext, config, { strapi }) => {
policyContext.request.body.data.links = policyContext.state.user.id;
},
],
},
},
});
How can i update my code so i will have the same function and fetch only the users todos… (‘connection’ is my collection name & ‘links’ is my relation to a user)
Thank you in advance!