dynamoose
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -22,2 +22,4 @@ 'use strict'; | ||
this.required = options.required; | ||
this.set = options.set; | ||
this.get = options.get; | ||
@@ -213,2 +215,6 @@ this.applyValidation(options.validate); | ||
if(this.set) { | ||
val = this.set(val); | ||
} | ||
var type = this.type; | ||
@@ -290,20 +296,36 @@ var isSet = this.isSet && !noSet; | ||
var val; | ||
switch(this.type.name) { | ||
case 'string': | ||
return dedynamofy('S', this.isSet, json); | ||
val = dedynamofy('S', this.isSet, json); | ||
break; | ||
case 'number': | ||
return dedynamofy('N', this.isSet, json, JSON.parse); | ||
val = dedynamofy('N', this.isSet, json, JSON.parse); | ||
break; | ||
case 'boolean': | ||
return dedynamofy('S', this.isSet, json, JSON.parse); | ||
val = dedynamofy('S', this.isSet, json, JSON.parse); | ||
break; | ||
case 'date': | ||
return dedynamofy('N', this.isSet, json, datify); | ||
val = dedynamofy('N', this.isSet, json, datify); | ||
break; | ||
case 'object': | ||
return dedynamofy('S', this.isSet, json, JSON.parse); | ||
val = dedynamofy('S', this.isSet, json, JSON.parse); | ||
break; | ||
case 'array': | ||
return dedynamofy('S', this.isSet, json, JSON.parse); | ||
val = dedynamofy('S', this.isSet, json, JSON.parse); | ||
break; | ||
case 'buffer': | ||
return dedynamofy('B', this.isSet, json, bufferify); | ||
val = dedynamofy('B', this.isSet, json, bufferify); | ||
break; | ||
default: | ||
throw new errors.SchemaError('Invalid attribute type: ' + this.type); | ||
} | ||
if(this.get) { | ||
val = this.get(val); | ||
} | ||
return val; | ||
}; | ||
@@ -310,0 +332,0 @@ |
{ | ||
"name": "dynamoose", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Dynamoose is a modeling tool for Amazon's DynamoDB (inspired by Mongoose)", | ||
"homepage": "https://github.com/automategreen/dynamoose", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/automategreen/dynamoose" | ||
}, | ||
"bugs": { | ||
"email": "support@automategreen.com", | ||
"url": "https://github.com/automategreen/dynamoose/issues" | ||
}, | ||
"main": "index.js", | ||
@@ -6,0 +15,0 @@ "scripts": { |
@@ -213,2 +213,10 @@ # Dynamoose [![Build Status](https://travis-ci.org/automategreen/dynamoose.png)](https://travis-ci.org/automategreen/dynamoose) | ||
**set**: function | ||
Adds a setter function that will be used to transform the value before writing to the DB. | ||
**get**: function | ||
Adds a getter function that will be used to transform the value return from the DB. | ||
**trim**: boolean | ||
@@ -215,0 +223,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
86258
2249
0
1
519
1