Skip to content

Async/await guide #7506

Closed
Closed
@JulioJu

Description

@JulioJu

Hi @libook @mhombach @vkarpov15

Following the issue #7461 I would propose to improve API documentation.

For instance, for https://mongoosejs.com/docs/api.html#model_Model.findOneAndUpdate

[Note: I've deleted a proposal here, because it was so bad]

Or instead as A query is not a fully-fledged promise (see https://mongoosejs.com/docs/promises.html) we could say instead:

Returns
    Query (a thenable object)

Like that a user that know what is a Promise and a thenable and what is a callback could know easy how to use this function. When I've started with Mongoose, I thought falsely « dash, mongoose API doesn't return Promise contrary to the mongodb native driver ».

It should be done for all CRUD operations, into lib/model.js and lib/query.js.

Furthermore https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/mongoose/index.d.ts should be updated accordingly. At least for this TypeScript definition file, we could say that: « findOneAndUpdate and others CRUD operations are Promises ».

What do you think about that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionIf you have any thoughts or comments on this issue, please share them!docsThis issue is due to a mistake or omission in the mongoosejs.com documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions