You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added optional generic support for the RecordService (#251).
This should allow specifying a single TypeScript definition for the client, eg. using type assertion:
interfaceTask{id: string;name: string;}interfacePost{id: string;title: string;active: boolean;}interfaceTypedPocketBaseextendsPocketBase{collection(idOrName: string): RecordService// default fallback for any other collectioncollection(idOrName: 'tasks'): RecordService<Task>collection(idOrName: 'posts'): RecordService<Post>}
...
constpb=newPocketBase('http://127.0.0.1:8090')asTypedPocketBase// the same as pb.collection('tasks').getOne<Task>("RECORD_ID")awaitpb.collection('tasks').getOne("RECORD_ID")// -> results in Task// the same as pb.collection('posts').getOne<Post>("RECORD_ID")awaitpb.collection('posts').getOne("RECORD_ID")// -> results in Post