zefhemel/persistencejs — Issue #73: Many-To-One setting problem: "Cannot read property 'list' of undefined"
Author: gorgo
Created: 2011-12-14 01:04:59+00:00
State: open

Hi, I've got a problem using Many-to-One relationship:

code:

persistence.store.websql.config(persistence, "testDb", "test", 5 * 1024 * 1024);

Category = persistence.define("Category", {
name: "TEXT"
});

ParamType = persistence.define("ParamType", {
name: "TEXT"
});
ParamType.hasOne("category", Category, "param_types");

persistence.schemaSync(function() {

console.log("created");
var category1 = new Category ({name: "category1"});
persistence.add(category1);

console.log(category1.id);
var param1 = new ParamType({name: "param1", category: category1});

//persistence.add(param1);

});

console:

persistence.store.websql.js:78CREATE TABLE IF NOT EXISTS `ParamType` (`name` TEXT, `category` VARCHAR(32), `id` VARCHAR(32) PRIMARY KEY) null
persistence.store.websql.js:78CREATE INDEX IF NOT EXISTS `ParamType__category` ON `ParamType` (`category`) null
persistence.store.websql.js:78CREATE TABLE IF NOT EXISTS `Category` (`name` TEXT, `id` VARCHAR(32) PRIMARY KEY) null
empty.html:25created
empty.html:292C19B80A37F548F88E745805FCB5CADA
persistence.js:440Uncaught TypeError: Cannot read property 'list' of undefined