nest-couchbase icon indicating copy to clipboard operation
nest-couchbase copied to clipboard

Further progress

Open atjeff opened this issue 5 years ago • 3 comments

Thanks for creating this project! I've been looking for nice typescript support for couchbase. I have your library up and running, but don't see many methods. Are you planning on adding some insert methods?

atjeff avatar Jan 15 '20 18:01 atjeff

I see, it does implement them all as it's just a wrapper, just the type definitions aren't finished. Thanks!

atjeff avatar Jan 15 '20 19:01 atjeff

@zMotivat0r How do you feel about changing repository.interface.ts to include something like this? It would keep you from having to manually add each method

export type Promisify<T> = {
  [K in keyof T]: T[K] extends (req: infer U, b: any, c: any, callback: (e: any, r: infer V) => void) => any
    ? (r: U) => Promise<V>
    : never
};

export interface Repository<T> extends Promisify<Bucket> {

I found that type here: https://github.com/microsoft/TypeScript/issues/26048

That will update your user.service.ts test to look like this:

image

No need to force casting to any

atjeff avatar Jan 15 '20 19:01 atjeff

@atjeff hey! Thanks a lot for your interest! I would love to see a PR because honestly, I'm not sure when I could find a time to update it :(

michaelyali avatar Jan 15 '20 20:01 michaelyali