dresende/node-orm — Issue #36: .save on model with some attributes not set
Author: shine-on
Created: 2012-02-12 13:10:47+00:00
State: open

Hola.

Assume one have model defined like this (coffee):

var Product = db.define("product1", {
name: String,
description: String,
created: Date
});

Later, when one do Person.save() on existing model using front-end supplied data not containing "created" (since it's supposed to be stored only on model's (C)reate, not (U)pdate), orm.js errors out:

orm.js:161
data[k] = (this[k].hasOwnProperty("toString") ? this[k].toString() : this
^
TypeError: Cannot call method 'hasOwnProperty' of undefined

It looks like one needs to pass full-blown attributes' set on every Person.save() which is not natural. What's wrong here?