Meteor-Community-Packages / meteor-collection2

A Meteor package that extends Mongo.Collection to provide support for specifying a schema and then validating against that schema when inserting and updating.
https://packosphere.com/aldeed/collection2
MIT License
1.02k stars 108 forks source link

defaultValue not set on upsert #306

Closed sungwoncho closed 6 years ago

sungwoncho commented 8 years ago

defaultValue is not set when a doc is inserted via upsert API.

e.g.

Books.attachSchema(new SimpleSchema({
  author: {
    type: String
  },
  title: {
    type: String,
    defaultValue: 'a',
    optional: true
  },
  price: {
    type: Number
  }
}));

Books.upsert({author: 'foo'}, {$set: {author: 'fooo', price: 1}});
// => no title is set.
sean-stanley commented 8 years ago

+1

nlhuykhang commented 8 years ago

+1

AlexanderArvidsson commented 8 years ago

+1

sungwoncho commented 8 years ago

Please don't comment +1 unless you are adding something to the discussion. There is a reaction button for that.

aldeed commented 6 years ago

Closing old issues. Most likely this has been fixed at some point in SimpleSchema package.