Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating with saveUnknown Fails #403

Closed
7 of 11 tasks
fishcharlie opened this issue Aug 3, 2018 · 1 comment
Closed
7 of 11 tasks

Updating with saveUnknown Fails #403

fishcharlie opened this issue Aug 3, 2018 · 1 comment
Labels

Comments

@fishcharlie
Copy link
Member

fishcharlie commented Aug 3, 2018

Summary:

Currently in Dynamoose when trying to update an item with saveUnknown set to true it fails silently.

Code sample:

Schema & Model

var Cat1 = dynamoose.model('Cat1', {
	id: {
		type: Number,
		validate: function(v) {
			return v > 0;
		},
		default: 888
	},
	name: {
		type: String,
		required: true,
		default: 'Mittens'
	},
	owner: String
}, {
	useDocumentTypes: true,
	saveUnknown: true
});

General

Cats.Cat1.create({id: 982, name: 'Oliver'}, function(err, old){
	should.not.exist(err);
	Cats.Cat1.update({id: old.id}, {otherProperty: 'Testing123'}, function(err, data){
		should.not.exist(err);
		should.exist(data);
		data.should.have.property('otherProperty');
		data.otherProperty.should.eql('Testing123');
		done();
	});
});

Current output and behavior:

I expect the test above to pass with no issues, due to the fact that saveUnknown is set to true, it should be saving all properties even if they are not in the schema.

Expected output and behavior:

Test is currently failing because it does not have property otherProperty.

Environment:

Node.js version (node -v): v10.6.0
NPM version: (npm -v): 6.1.0
Dynamoose version: master branch

Other information (if applicable):

Type (select 1):

  • Bug report
  • Feature suggestion
  • Question
  • Other suggestion
  • Something not listed here

Other:

  • I have read through the Dynamoose documentation before posting this issue
  • I have searched through the GitHub issues (including closed issues) and pull requests to ensure this issue has not already been raised before
  • I have searched the internet and Stack Overflow to ensure this issue hasn't been raised or answered before
  • I have tested the code provided and am confident it doesn't work as intended
  • I have filled out all fields above
  • I am running the latest version of Dynamoose
@fishcharlie
Copy link
Member Author

Closed in #431

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant