Created
December 17, 2010 20:04
-
-
Save erichocean/745609 to your computer and use it in GitHub Desktop.
query-based to many relationship
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
messages: SC.RecordAttribute.create({ | |
toType: function(record, key, value) { | |
var ary = record._messages ; | |
if (!ary) { | |
console.log('creating a messages query for Mailbox[%@]'.fmt(record.get('guid'))); | |
CoreOI.Record.messages++ ; | |
ary = record._messages = record.get('store').findAll(SC.Query.create({ | |
recordType: 'CoreOI.Message', | |
conditions: "mailbox = %@", | |
parameters: [record], | |
orderBy: "dateSent DESC" | |
})); | |
} else { | |
console.log('verifying freshness of messages query for Mailbox[%@]'.fmt(record.get('guid'))); | |
ary.refresh() ; | |
} | |
return ary ; | |
} | |
}), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment