Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Handle undefined and boolean

  • Loading branch information...
commit 856a8633703f1aca6a5fc5fee0fb634c91870943 1 parent 6346c6e
@1602 1602 authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 lib/sqlite3.js
View
10 lib/sqlite3.js
@@ -215,9 +215,17 @@ SQLite3.prototype.fromDatabase = function (model, data) {
var props = this._models[model].properties;
Object.keys(data).forEach(function (key) {
var val = data[key];
+ if (typeof val === 'undefined' || val === null) {
+ return;
+ }
if (props[key]) {
- if (props[key].type.name === 'Date') {
+ switch (props[key].type.name) {
+ case 'Date':
val = new Date(parseInt(val));
+ break;
+ case 'Boolean':
+ val = new Boolean(val);
+ break;
}
}
data[key] = val;
Please sign in to comment.
Something went wrong with that request. Please try again.