
Hello 👋, quick question about Type generation and Relationships in Typescript. There might be an "issue" using createDocument
for relations, only the parameter $id
is required, but the Type generation assigns whole type. What would be the ideal way to deal with it?
appwrite.d.ts
export type Items = Models.Document & {
name: string;
}
export type Users = Models.Document & {
username: string;
}
export type Favorites = Models.Document & {
item: Items;
user: Users;
}
databases.createDocument(
ID.unique(),
{
item: items.$id, // Error: Type string is not assignable to type Items
user: users.$id, // Error: Type string is not assignable to type Users
},
);
And also, the appwrite.d.ts
generator write the type name as plural (Items, Users, Favorites) instead of singular (Item, User, Favorite), is it intentional? From source code I found that it uses the collection name, but automatically creating singular from plural would be more appropriate? Is it recommended to use singular name of the collection to avoid this?
Recommended threads
- Auth Email Template
Hi, i would like to ask is it doable to make multiple email sender in one project?
- Vite build permission failed
im trying to deploy a react site using appwrite sites and it keeps failing to build ```2025-08-10T20:20:15.168371867Z [20:20:15] [open-runtimes] Environment pr...
- How to proper delete a serverless functi...
I tried `appwrite functions delete --function-id 12345`, it deletes the online one, but even after trying `appwrite pull functions`, the local one in the appwri...
