Skip to content
Back

Type generation without $id parameter

  • 0
  • Databases
  • Flutter
Maryusz
8 Jul, 2025, 21:21

I'm trying for the first time appwrite on 2 projects and after I've tested appwrite types generation with the cli I'm a little bit confused why it doesn't include or handle the $id field which is fundamental to handle relationships.

I'm not finding anything about it in the documentation and I understand that it is reported that the relationships are in an experimental phase but rather it makes me think that I'm doing something wrong or is it intentional?

What is the best way to relate collections of documents in this case?

Thank you very much 🙂

TL;DR
Developers are generating types without the $id parameter when using the type generator with the -l ts option. This issue does not occur when generating types for Dart and PHP. It is recommended to extend appwrite's base type when creating custom types that require the $id field. The documentation does not provide clear information on this issue. The best way to relate collections of documents in this case is by extending the appropriate base types provided by appwrite.
Kenny
8 Jul, 2025, 21:41

$id and similar attributes are apart of the models provided by appwrite. Your type should extend appwrites base type. Does the type generator not do this?

Kenny
8 Jul, 2025, 21:42

Similar to this

TypeScript
export type Books = Models.Document & {
  name: string;
  author: string;
  releaseYear: string | null;
  category: Category | null;
  genre: string[] | null;
  isCheckedOut: boolean;
}

We are extending the Models.Document type, which includes $id, $createdAt, etc.

Maryusz
8 Jul, 2025, 21:48

I only saw right now that when generating types with -l ts option it does generate the extended classes, but this doesn't happen for dart and PHP. 🤔

Kenny
8 Jul, 2025, 21:54

seems like only ts pulls with the base types. idk if that's intended or not. Seems weird to me.

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