Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support generics for TypeScript #49

Open
SamVerschueren opened this issue Mar 24, 2017 · 1 comment
Open

Support generics for TypeScript #49

SamVerschueren opened this issue Mar 24, 2017 · 1 comment

Comments

@SamVerschueren
Copy link
Owner

SamVerschueren commented Mar 24, 2017

It would be nice if we could do something like this

interface User {
    id: string;
    name: string;
}

const UserTable = db.table<User>('User');

const result = UserTable.find().exec();
//=> result is now recognized as `User[]` so we can map over it etc.

Something we have to take into account is that when using limit(1) or findOne() it doesn't return an array but a single instance. Not sure if we can define that somehow.

@BenjaminPalko
Copy link

@SamVerschueren #89 I did just that :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants