Socket
Socket
Sign inDemoInstall

camo

Package Overview
Dependencies
124
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.3 to 0.5.4

5

CHANGELOG.md

@@ -0,1 +1,6 @@

## 0.5.4 (2015-07-09)
Bugfixes:
- Fixed issue where `Date`s were saved in different formats (integers, `Date` objects, etc). Added way to canonicalize them so all dates look the same in the DB and are also loaded as Date objects.
## 0.5.3 (2015-07-01)

@@ -2,0 +7,0 @@

@@ -12,2 +12,3 @@ "use strict";

var isString = require('./validate').isString;
var isNumber = require('./validate').isNumber;

@@ -159,2 +160,3 @@ var normalizeType = function(property) {

// TODO: This should probably be in Document, not BaseDocument
if (value !== null && value !== undefined &&

@@ -203,2 +205,24 @@ value.documentClass && value.documentClass() === 'embedded') {

/*
* Right now this only canonicalizes dates (integer timestamps
* get converted to Date objects), but maybe we should do the
* same for strings (UTF, Unicode, ASCII, etc)?
*/
canonicalize() {
var that = this;
_.keys(that._values).forEach(function(key) {
var value = that._values[key];
if (that._schema[key].type === Date && isNumber(value)) {
that._values[key] = new Date(value);
} else if (value !== null && value !== undefined &&
value.documentClass && value.documentClass() === 'embedded') {
// TODO: This should probably be in Document, not BaseDocument
value.canonicalize();
return;
}
});
}
static create(data) {

@@ -205,0 +229,0 @@ if (typeof(data) !== 'undefined') {

3

lib/document.js

@@ -83,2 +83,5 @@ "use strict";

// Ensure all data types are saved in the same encodings
that.canonicalize();
// TODO: We should instead track what has changed and

@@ -85,0 +88,0 @@ // only update those values. Maybe make that._changed

4

package.json
{
"name": "camo",
"version": "0.5.3",
"description": "A lightweight ES6 ODM for Mongo-like databases.",
"version": "0.5.4",
"description": "A class-based ES6 ODM for Mongo-like databases.",
"author": {

@@ -6,0 +6,0 @@ "name": "Scott Robinson",

@@ -26,3 +26,3 @@ var expect = require('chai').expect;

expect(d).to.have.property('values').with.length(3);
expect(d.date).to.be.equal(1434304033241);
expect(d.date.valueOf()).to.be.equal(1434304033241);
};

@@ -45,3 +45,3 @@

expect(d).to.have.property('values').with.length(4);
expect(d.date).to.be.equal(1434304039234);
expect(d.date.valueOf()).to.be.equal(1434304039234);
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc