Closed saqlainzaheer closed 1 month ago
Hey @saqlainzaheer check your patient schema and the data-type assigned to these parameters. I problem remains unsolved, delete these params and create them again. Also, check the appointment
schema properly from the video that's the only tricky part.
The issue isn't related to the schema, as the schema is correct and patients register successfully. However, the problem arises on the appointment page when creating an appointment.
In the createAppointment function, I used the following approach:
{
...appointment,
patient: [appointment.patient]
}
instead of this
const newAppointment = await databases.createDocument(
DATABASE_ID!,
APPOINTMENT_COLLECTION_ID!,
ID.unique(),
**appointment**
);
revalidatePath("/admin");
return parseStringify(newAppointment);
The reason for this change is that the relationship is one-to-many, so it requires an array of patient IDs rather than a single patient ID.
relation is many to one . appointment can contain one patient patient can belong to many appointment
Oh, yes, you are right. I made the relationship one-to-many instead of many-to-one. Thanks for the clarification.
Issue Description: Encountered "Invalid relationship value" error when creating an appointment using the createDocument method in the Appwrite SDK. CODE:
ERROR
Expected Behavior:
I expected the SDK to handle a single document ID correctly in the patientId field and create the appointment
Steps to Reproduce: Define a CreateAppointmentParams object with a patientId field that is expected to be an array of strings. Call createDocument with this object, passing a single string instead of an array of strings for patientId. Observe the error thrown by the SDK. CORECT CODE SHUOLD BE