New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

api-orm

Package Overview
Dependencies
Maintainers
2
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-orm - npm Package Compare versions

Comparing version 0.0.1 to 0.0.3

18

lib/instance.js

@@ -117,5 +117,5 @@ var util = require('util'),

}
if (hasValue && field.type.toLowerCase() !== typeof(value).toLowerCase()) {
if (hasValue && field.type.toLowerCase() !== (typeof value).toLowerCase()) {
if (!this.validateCoersiveTypes(field,name,value)) {
throw new ValidationError(name,"invalid type ("+typeof(value)+") for field: "+name+". Should be "+field.type+". Value was: "+util.inspect(value));
throw new ValidationError(name,"invalid type ("+(typeof value)+") for field: "+name+". Should be "+field.type+". Value was: "+util.inspect(value));
}

@@ -175,2 +175,14 @@ }

Instance.prototype.toPayload = function toPayload() {
var obj = {},
fields = this._model.fields,
values = this.values();
for (var key in values) {
if (values.hasOwnProperty(key) && values[key] !== null) {
obj[fields[key].name || key] = values[key];
}
}
return obj;
};
Instance.prototype.isUnsaved = function isUnsaved() {

@@ -234,3 +246,3 @@ return this._dirty;

// see if we have a field remapping
if (!skipNotFound && name in this._fieldmap) {
if (name in this._fieldmap) {
name = this._fieldmap[name];

@@ -237,0 +249,0 @@ }

5

lib/model.js

@@ -413,3 +413,6 @@ var util = require('util'),

catch(err) {
// Oh well, carry on!
if (key === 'where') {
err.message = 'Failed to parse "where" as JSON: ' + err.message;
throw err;
}
}

@@ -416,0 +419,0 @@ }

{
"name": "api-orm",
"version": "0.0.1",
"version": "0.0.3",
"description": "API Builder ORM",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -92,2 +92,31 @@ var should = require('should'),

it('should be able get payloads for servers',function(callback){
var Connector = new orm.MemoryConnector();
var User = orm.Model.define('user',{
fields: {
name: {
name: 'internalName',
type: String,
default: 'Jeff'
},
age: {
type: Number,
default: 10
}
},
connector: Connector
});
User.create(function(err,instance){
should(err).be.not.ok;
should(instance).be.an.Object;
var payload = instance.toPayload();
should(payload).be.an.Object;
should(payload.internalName).be.ok;
should(payload.age).be.ok;
callback();
});
});
it('should be able to create with defaults',function(callback){

@@ -94,0 +123,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc