Back

[CLOSED] after bad request my databases have been broken

  • 0
  • Databases
  • Cloud
Bogdan Tvarina
13 Nov, 2023, 07:26

I wanted to add new post and after bad request users and posts collections have been broken. ProjectId: 65494a51aaa5cddd045f

TL;DR
After a bad request, the user's databases were broken. They tried deleting the project but the issue persisted. Another user suggested creating a new project to solve the issue. The user confirmed that they did not have any important data in the project. The user also provided a code snippet for creating a post, uploading a file, getting a file preview, and deleting a file. It seems that the issue occurred while trying to create a post. No solution was provided in the thread.
Drake
13 Nov, 2023, 19:19

are you still experiencing this?

D5
13 Nov, 2023, 19:28

And what was the request? 👀

Bogdan Tvarina
14 Nov, 2023, 14:07

yes

Bogdan Tvarina
14 Nov, 2023, 14:09

` export async function createPost(post: INewPost) { try { const uploadedFile = await uploadFile(post.file[0]);

TypeScript
    if (!uploadedFile) throw Error;

    const fileUrl = getFilePreview(uploadedFile.$id);

    if (!fileUrl) {
        deleteFile(uploadedFile.$id);
        throw Error;
    }

    const tags = post.tags?.replace(/ /g, '').split(',') || [];

    const newPost = await databases.createDocument(
        appwriteConfig.databaseId,
        appwriteConfig.postsCollectionId,
        ID.unique(),
        {
            creator: post.userId,
            caption: post.caption,
            imageUrl: fileUrl,
            imageId: uploadedFile.$id,
            location: post.location,
            tags,
        }
    );
    if (!newPost) {
        await deleteFile(uploadedFile.$id);
        throw Error;
    }
    return newPost;
} catch (error) {
    console.log(error);
}

}

export async function uploadFile(file: File) { try { const uploadedFile = await storage.createFile(appwriteConfig.storageId, ID.unique(), file);

TypeScript
    return uploadedFile;
} catch (error) {
    console.log(error);
}

}

export async function getFilePreview(fileId: string) { try { const fileUrl = storage.getFilePreview(appwriteConfig.storageId, fileId, 2000, 2000, 'top', 100); return fileUrl; } catch (error) { console.log(error); } } export async function deleteFile(fileId: string) { try { await storage.deleteFile(appwriteConfig.storageId, fileId);

TypeScript
    return { status: 'ok' };
} catch (error) {
    console.log(error);
}

} `

Bogdan Tvarina
14 Nov, 2023, 14:10

I wanted to create a post

Bogdan Tvarina
14 Nov, 2023, 14:12

and my users and posts collections are still broken

Bogdan Tvarina
14 Nov, 2023, 14:12

after just 1 request)

D5
14 Nov, 2023, 15:40

@Bogdan TvarinaDid you have users in this project?

Bogdan Tvarina
14 Nov, 2023, 15:53

Yes, my test accounts)

D5
14 Nov, 2023, 15:54

And when do you have created this project?

D5
14 Nov, 2023, 15:54

If it doesn't has something important, creating a new project should solve the issue

Bogdan Tvarina
14 Nov, 2023, 15:54

Ok, ty...

Haimantika
14 Nov, 2023, 16:39

@Bogdan Tvarina does it work for you now? We had some ongoing issues

Bogdan Tvarina
14 Nov, 2023, 16:50

of course) just deleted project

Haimantika
14 Nov, 2023, 16:54

Okay cool. Marking this one as closed. Feel free to reopen if you face it again

Haimantika
14 Nov, 2023, 16:54

[CLOSED] after bad request my databases have been broken

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more