Ahsen Mehmood
Ahsen Mehmood

Reputation: 1

Appwrite db connection issue to register a patient

An error occurred while creating a new patient: AppwriteException: Missing required parameter: "databaseId" at createDocument (lib\actions\patient.actions.ts:59:36)

I keep getting this error in my patient.action.ts file when connecting with the db. I have pasted my code below

export const registerPatient = async ({
    identificationDocument,
    ...patient
}: RegisterUserParams) => {
    try {
        
        let file;
        if (identificationDocument) {
            const inputFile =
                identificationDocument &&
                InputFile.fromBuffer(
                    identificationDocument?.get("blobFile") as Blob,
                    identificationDocument?.get("fileName") as string
                );

            file = await storage.createFile(BUCKET_ID!, ID.unique(), inputFile);
        }

        const newPatient = await db.createDocument(
            DATABASE_ID!,
            PATIENT_COLLECTION_ID!,
            ID.unique(),
            {
                identificationDocumentId: file?.$id ? file.$id : null,
                identificationDocumentUrl: file?.$id
                    ? `${ENDPOINT}/storage/buckets/${BUCKET_ID}/files/${file.$id}/view??project=${PROJECT_ID}`
                    : null,
                ...patient,
            }
        );

I have tried debugging the code have tried to change it many times but I keep getting the same error

Upvotes: 0

Views: 7

Answers (0)

Related Questions