Web Developer
I try to create a row in my table but when i submit i have an error on my permission, i'm new on it so i dont understand the error. I have Row Security enable
export const createGoal = async ( {
exercise,
progress,
total,
}: CreateGoalParams ) => {
const currentUser = await getCurrentUser();
if ( !currentUser ) {
throw new Error( "Utilisateur non connecté" );
}
// Vérifier limite objectifs actifs
const existingGoals = await getGoalsFromUser();
const activeGoals = existingGoals.filter(
( g ) => g.state === "in-progress"
);
if ( activeGoals.length >= LIMITS.MAX_GOALS ) {
return {
message: {
title: "Limite atteinte",
body: Maximum ${LIMITS.MAX_GOALS} objectifs en cours.,
},
};
}
const newRow = await tablesDB.createRow( {
databaseId,
tableId: goalTable,
rowId: ID.unique(),
data: {
exercise,
progress,
targetValue: total,
progressHistory: [ progress ],
state: "in-progress",
},
permissions: [
Permission.read( Role.user( currentUser.$id ) ),
Permission.update( Role.user( currentUser.$id ) ),
Permission.delete( Role.user( currentUser.$id ) ),
],
} );
const goal = await buildGoalObject( newRow );
return {
goal,
message: {
title: "Objectif créé",
body: "Votre objectif a été créé avec succès.",
},
};
};