bwgjoseph / mongoose-vs-ottoman

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

replaceById does not completely replace doc #78

Closed bwgjoseph closed 3 years ago

bwgjoseph commented 3 years ago

Hi,

I have the following test case

const replaceSchema = new Schema({ name: String, age: Number });
const replaceModel = model('myReplace', replaceSchema);
const replaceData = new replaceModel({ name: 'ivan', age: 32 });
const created = await replaceModel.create(replaceData);

assert.strictEqual(created.name, 'ivan');
assert.strictEqual(created.age, 32);

const replaced = await replaceModel.replaceById(created.id, { id: created.id, name: 'joseph' });

assert.strictEqual(replaced.name, 'joseph');
assert.ok(!replaced.age);

The output is as such

// after create
_Model {
  name: 'ivan',
  age: 32,
  id: '223193f0-e1fa-4e7c-99c2-ddc5b8d29134',
  _type: 'myReplace'
}

// after replaceById
_Model {
  name: 'joseph',
  age: 32,
  id: '223193f0-e1fa-4e7c-99c2-ddc5b8d29134',
  _type: 'myReplace'
}

Notice that age property still exists after replaceById is ran which shouldn't be the case

AV25242 commented 3 years ago

Will look into it.

AV25242 commented 3 years ago

I have created an Investigation ticket on our side to review this.

bwgjoseph commented 3 years ago

@AV25242 Appreciate it if this could be of higher priority, thanks!

AV25242 commented 3 years ago

Sure will target this for the next release @bwgjoseph

httpJunkie commented 3 years ago

Fixed w/ alpha 29