Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Document#set ignores strict mode #916

Closed
kof opened this Issue · 2 comments

3 participants

@kof

If I use path and value as a separate params, it will ignore strict mode of the scheme and save it.

var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var assert = require('assert');

mongoose.connect('localhost', 'strict');

var user = new Schema({
    name: String
}, {strict: true});

var User = mongoose.model('user', user);

mongoose.connection.on('open', function () {
  var u = new User();

  u.set('some.bad.path', 'someBadValue');
  u.save(function(err) {
    assert.equal(null, err);
    User.findOne({'some.bad.path': 'someBadValue'}, function(err, u) {
      assert.equal(null, u);
      mongoose.connection.db.dropDatabase(function () {
        mongoose.connection.close();
      });
    });
  });
});
@aheckmann
Owner

thanks for the report

@aheckmann aheckmann closed this in 2255075
@aheckmann aheckmann referenced this issue from a commit in aheckmann/mongoose
@aheckmann aheckmann fixed; setting invalid paths in strict mode
closes #916
64cd842
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.