#Duplicate name types with multiple databases

1 messages · Page 1 of 1 (latest)

languid notch
#

Hello,

we are having multiple databases and would like to use the cli to generate the types using (appwrite types --language ts), the issue is that the appwrite.d.ts only generates the names of Collection without the Database name as prefix.

For example, databases

MyPrimaryDatabase
   Users
       first_name: string
MySecondaryDatabase
    Users
        last_name: string

❌ The CLI will generate duplicate types like this:

export type Users = Models.Document & {
    first_name: string;
}

export type Users = Models.Document & {
    last_name: string;
}

✅ It would be better to use the database name as prefix like this:

export interface MyPrimaryDatabase{
    Users: Models.Document & {
        first_name: string;
    },
}

export interface MySecondaryDatabase{
    Users: Models.Document & {
        last_name: string;
    },
}

Thank you

#

Duplicate name types with multiple databases

whole hull
#

cc @ebon ferry

languid notch
#

Another idea is to create multiple files or folders named after the database

ebon ferry
# languid notch Hello, we are having multiple databases and would like to use the cli to genera...

Hi there, this seems like a very specifc issue. Type Generation is meant to provide a starting point for types and cover most the basic use cases. Most users only have a single database linked to their project, or if they are having many, they won't have duplicate collections like this.

Having database prefix and be used as an interface is a very simple addition you can make to your code for your use case, but for almost all users its just extra complexity

ebon ferry
ebon ferry
#

Noted it down 👌