I am trying to get my types sorted out with the custom collection schema. I am trying to add my custom properties to Models.Document like this:
interface Picture extends Models.Document {
user_id: string,
name: string,
pic_id: string,
an: number,
descriere: string
}
And trying to use it like this:
db.listDocuments(..).documents.map((a: Picture) => {});
Except, it's not compatible: ts
Argument of type '(a: Picture) => { user_id: string; name: string; pic_id: string; an: number; descriere: string; }' is not assignable to parameter of type '(value: Document, index: number, array: Document[]) => { user_id: string; name: string; pic_id: string; an: number; descriere: string; }'.ts(2345)
What would be the solution?
I think you need to force the assertion.
type Picture = Models.Document & {
user_id: string,
name: string,
pic_id: string,
an: number,
descriere: string
}
Basically it's the same as you but with a "type"
fixed it
thanks!
π
[SOLVED] Custom types for document attributes
Recommended threads
- Is possible to extend timeout function m...
I will have function to backup/aggregate and syncing data. it will take alot of time. anyway to run longer, i expect 1hours
- databases.listDocuments fails when Query...
Hi, databases.listDocuments fails when Query.limit above 1000. Fetch type error: terminated when run inside a function, but seems to work with lower limits, e...
- Help with OAuth2 and Discord
Hi everyone, I've been looking for the past day for solutions to my error in my code with making Discord and Appwrite work on my NextJS project. This project is...