AD Amorim
AD Amorim
XXata
Created by AD Amorim on 8/1/2024 in #help
Vercel integration is not setting the XATA_BRANCH
No description
4 replies
XXata
Created by AD Amorim on 7/18/2024 in #help
what is the ideal column type to store the content of a Tiptap editor?
I’m building page the saves the whole document provided by the rich text editor using tiptap. I was wondering if the ideal column type would be text or json. Not sure about the the pros and cons of both when considered things like performance, amount of data it can store, compatibility with other databases like SQLite etc. My current requirement is just to query the whole document at page load and update it when the user changes the content with some debouncing. Appreciate any suggestions!
10 replies
XXata
Created by AD Amorim on 6/12/2024 in #help
how to make am update request without returning Xata metadata?
The code below calls: const proj = await xata.db.project.update(id, data); I would like to remove the metadata that comes from it in order to avoid parsing errors from zod at: project.parse(proj) Is that possible? I know we can do this when getting data but not sure how the update transaction does that.
export const updateProject = async (
id: ProjectRecord["id"],
data: Partial<Project>
) => {
// If data validation fails, return errors early. Otherwise, continue.
const validatedFields = project.omit({ id: true, clockify_id: true }).safeParse(data);
if (!validatedFields.success) {
return {
errors: validatedFields.error.flatten().fieldErrors,
message: "Missing Fields. Failed to Update Project.",
};
}

try {
const proj = await xata.db.project.update(id, data);

return project.parse(proj);
} catch (error) {
console.error("Failed to Update Project.", error);
// If a database error occurs, return a more specific error.
return {
errors: error,
message: "Database Error: Failed to Update Project.",
};
}
};
export const updateProject = async (
id: ProjectRecord["id"],
data: Partial<Project>
) => {
// If data validation fails, return errors early. Otherwise, continue.
const validatedFields = project.omit({ id: true, clockify_id: true }).safeParse(data);
if (!validatedFields.success) {
return {
errors: validatedFields.error.flatten().fieldErrors,
message: "Missing Fields. Failed to Update Project.",
};
}

try {
const proj = await xata.db.project.update(id, data);

return project.parse(proj);
} catch (error) {
console.error("Failed to Update Project.", error);
// If a database error occurs, return a more specific error.
return {
errors: error,
message: "Database Error: Failed to Update Project.",
};
}
};
5 replies