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

Wrong generic type for findAsync method #57

Open
dremchee opened this issue May 24, 2024 · 3 comments
Open

Wrong generic type for findAsync method #57

dremchee opened this issue May 24, 2024 · 3 comments

Comments

@dremchee
Copy link

): Nedb.Cursor<T[]>;

I think it should be like this Document<T>[] instead of T[]

@arantes555
Copy link

@dremchee I believe Nedb.Cursor<T> extends Promise<Document<T>>, so it should already be the case once awaited, or am I wrong ?

@dremchee
Copy link
Author

@dremchee I believe Nedb.Cursor<T> extends Promise<Document<T>>, so it should already be the case once awaited, or am I wrong ?

I mean the findAsync method, which should return an array
For example sandbox https://codesandbox.io/p/sandbox/nedb-generic-type-pr8lvv?file=%2Fsrc%2Findex.ts%3A13%2C1

image
image

@RobMayer
Copy link

I just encountered this. @dremchee is right.

// CURRENT BEHAVIOUR
const cursor = db.findAsync({ id: { $in: someArray}}(; // Cursor<T[]>
const result = await cursor.execAsync;() // Document<T[]>
result[0]._id // Should be a valid property but isn't showing up
result._id // Shouldn't be a valid property but is showing up

// EXPECTED BEHAVIOUR
const cursor = db.findAsync({ id: { $in: someArray}}(; // Cursor<T[]>
const result = await cursor.execAsync;() // Document<T>[]

result[0]._id // each row has an _id, does it now?

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

No branches or pull requests

3 participants