Skip to content

Instantly share code, notes, and snippets.

@thomaslang
Created August 10, 2009 19:33
Show Gist options
  • Save thomaslang/165366 to your computer and use it in GitHub Desktop.
Save thomaslang/165366 to your computer and use it in GitHub Desktop.
//descriptions: SC.RecordAttribute.create({
// toType: function(record, key, value) {
// var cacheKey = '__descriptions__'+ SC.guidFor(record) ;
// var query = record[cacheKey] ;
// if (!query) {
// query = record[cacheKey] = record.get('store').findAll(SC.Query.create({
// recordType: 'BB.Description',
// conditions: "concept = %@",
// parameters: [record]
// // orderBy: "priority DESC, lowerCaseName"
// }));
// }
// return query ;
// }
//}),
descriptions: SC.RecordAttribute.create({
toType: function(record, key, value) {
var queryCacheKey = '__descriptionsQuery__'+ SC.guidFor(record) ;
var query = record[queryCacheKey] ;
var resultsCacheKey = '__descriptions__'+ SC.guidFor(record) ;
var results = record[resultsCacheKey] ;
if (!query) {
query = record[queryCacheKey] = SC.Query.create({
recordType: 'BB.Description',
conditions: "concept = %@",
parameters: [record]
// orderBy: "priority DESC, lowerCaseName"
});
}
if (!results) {
results = record[resultsCacheKey] = record.get('store').findAll(query);
}
return results ;
}
}),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment