bwgjoseph / mongoose-vs-ottoman

feature comparison between mongoose and ottoman
0 stars 1 forks source link

ManyResponse interface declaration #100

Closed bwgjoseph closed 3 years ago

bwgjoseph commented 3 years ago

I mean the interface

// should be
export interface ManyResponse {
    // note, no ?
    data: any[];
    match_number: number;
    success: number;
    errors: StatusExecution[];
}

// instead of
export interface ManyResponse {
    data?: any[];
    match_number: number;
    success: number;
    errors: StatusExecution[];
}

Since that, all multi-methods will always return data, it doesn't make sense to make it optional unless there is case where data is not being returned

Originally posted by @bwgjoseph in https://github.com/bwgjoseph/mongoose-vs-ottoman/issues/82#issuecomment-856892249

AV25242 commented 3 years ago

@bwgjoseph what I have been told is that data will always be returned even if its an empty array

bwgjoseph commented 3 years ago

Yup, that's correct.

The issue here is that the interface is declared that the data might not be returned (optional as it was declared with ?)

As mentioned in the first post, the correct interface declaration should be

export interface ManyResponse {
    // notice that there is no ? (question mark) after data
    data: T[];
    match_number: number;
    success: number;
    errors: StatusExecution[];
}

Below is the current declaration (with ? after data)

https://github.com/couchbaselabs/node-ottoman/blob/89520f200100600bc20ce08670a3cd8c8c4cc05a/src/handler/types.ts#L54-L59

AV25242 commented 3 years ago

Ah ok, let me open a ticket to address this and see what is the response

AV25242 commented 3 years ago

v2.0.0-beta.3 released