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
- Rate límit reset
I've made an error in the code by not setting a limit on how much rows should i get per request because i was working with a small db for testing. Last night Iv...
- How to set permissions using the createO...
Hi, I'm trying to create a set of registers in a table using the tableDB.createOperations function, but it seems like it doesnt support/expect the usage of the ...
- Appwrite not sending Emails
I’m running a self-hosted Appwrite instance (v1.8.1) and I can’t get invite emails to send when using the team invite flow described in the docs: https://appwri...