bwgjoseph / mongoose-vs-ottoman

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

Support for returning docs as result in *Many ops #68

Closed bwgjoseph closed 3 years ago

bwgjoseph commented 3 years ago

Hi,

Is it possible to return the docs that were created/updated/removed in the *Many operations instead of the ManyQueryResponse when a param is passed in such as (for example) new: true or raw: true?

const data = [{ name: 'data1' }, { name: 'data2' }];
const results = model.createMany(data, { raw: true });

// results
[
  {
    id: '12345',
    name: 'data1'
  },
  {
    id: '23456',
    name: 'data2'
  }
]

or alternatively, appending the raw result from the creations onto ManyQueryResponse like

status: 'SUCCESS',
message: {
    success: 2,
    match_number: 2,
    errors: [],
},
data: [
    {
        id: '12345',
        name: 'data1'
    },
    {
        id: '23456',
        name: 'data2'
    }
]
AV25242 commented 3 years ago

@bwgjoseph will need to discuss it more will shelve it for future

httpJunkie commented 3 years ago

same for updateMany()

bwgjoseph commented 3 years ago

@httpJunkie @AV25242

To further iterate on this issue with the assumption of the database already having 100 documents,

The removeMany is slightly different from the removeById case where I do know which id I passed into the API for deletion. In removeMany case, I do not know what are removed

Hence, I would think this is a critical issue for the API instead of a future issue, otherwise, the API wouldn't be of much use


Some reference

AV25242 commented 3 years ago

The issues are created to investigate viable options and see if this is feasible.

AV25242 commented 3 years ago

I thought this is available to you know please review and let me know.

bwgjoseph commented 3 years ago

Sorry, might have missed this. Will take a look later

bwgjoseph commented 3 years ago

Have verified it