Hey Everyone,
I'm working on an HTML5 and I can get it work alright, but I'm having problems with setting entity relationships.
I have the following to define the entities:
var AccountEntity = persistence.define('Account', {
remoteId: "TEXT",
lastModified: "DATE",
deleted: "BOOL",
needsPushing: "BOOL",
name: "TEXT NOT NULL",
defaultAmount: "REAL",
});
var BillEntity = persistence.define('Bill', {
remoteId: "TEXT",
lastModified: "DATE",
deleted: "BOOL",
needsPushing: "BOOL",
accountId: "VARCHAR(32) NOT NULL",
date: "DATE",
amount: "REAL",
});
BillEntity.hasOne('account', AccountEntity);
AccountEntity.hasMany('bills', BillEntity, 'account');
I can add the bills and accounts fine (I assume), but when I query the bills and try to get the account associated with the bill, it comes back null.
Example query:
BillEntity.all().and(deletedAndPaidFilter).prefetch('account').order('date', true).list(null, function (results) {
// Accessing bill.account() returns null
// Accessing bill.account prints out a function definition
}
What step(s) am I missing?
Thanks in advance!