Skip to content

Commit

Permalink
fixup! apply review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
biniam committed Apr 12, 2019
1 parent 8df8f80 commit 6dc076d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/mongodb.js
Expand Up @@ -2033,7 +2033,7 @@ function visitAllProperties(data, modelCtorOrDef, visitor) {
* Decimal128 type
*/
function coerceDecimalProperty(propValue, propDef, setValue) {
var updatedValue;
let updatedValue;
if (hasDataType('decimal128', propDef)) {
if (Array.isArray(propValue)) {
updatedValue = propValue.map(val => Decimal128.fromString(val));
Expand Down
17 changes: 6 additions & 11 deletions test/decimal.test.js
Expand Up @@ -9,12 +9,7 @@ require('./init.js');
const promisify = require('bluebird').promisify;
const Decimal128 = require('mongodb').Decimal128;

var db,
OrderDecimal,
modelWithDecimalArray,
modelWithDecimalNestedArray,
modelWithDecimalNestedObject,
modelWithDeepNestedDecimalProps;
var db, OrderDecimal;

describe('model with decimal property', function() {
before(function(done) {
Expand Down Expand Up @@ -70,7 +65,7 @@ describe('model with decimal property', function() {

context('nested decimal props', function() {
it('should create/update instance for array of decimal props', function() {
modelWithDecimalArray = db.define('modelWithDecimalArray', {
const modelWithDecimalArray = db.define('modelWithDecimalArray', {
randomReview: {
type: [String],
mongodb: {
Expand Down Expand Up @@ -116,7 +111,7 @@ describe('model with decimal property', function() {
});
});
it('should create/update instance for nested decimal prop inside array', function() {
modelWithDecimalNestedArray = db.define('modelWithDecimalNestedArray', {
const modelWithDecimalNestedArray = db.define('modelWithDecimalNestedArray', {
tickets: {
type: [
{
Expand Down Expand Up @@ -167,7 +162,7 @@ describe('model with decimal property', function() {
};
let instanceId;

modelWithDecimalNestedArray.create(createData)
return modelWithDecimalNestedArray.create(createData)
.then(function(inst) {
instanceId = inst.id;
return findRawModelDataAsync('modelWithDecimalNestedArray', instanceId);
Expand All @@ -187,7 +182,7 @@ describe('model with decimal property', function() {
});

it('should create/update instance for nested decimal prop inside object', function() {
modelWithDecimalNestedObject = db.define('modelWithDecimalNestedObject', {
const modelWithDecimalNestedObject = db.define('modelWithDecimalNestedObject', {
awards: {
type: {
wins: {
Expand Down Expand Up @@ -242,7 +237,7 @@ describe('model with decimal property', function() {
});
});
it('should create/update instance for deeply nested decimal props', function() {
modelWithDeepNestedDecimalProps = db.define('modelWithDeepNestedDecimalProps', {
const modelWithDeepNestedDecimalProps = db.define('modelWithDeepNestedDecimalProps', {
imdb: {
type: {
duration: {
Expand Down

0 comments on commit 6dc076d

Please sign in to comment.