Last active
March 2, 2018 18:35
-
-
Save AmilKey/56b021df6dff9d8b946a0737a7e76bae to your computer and use it in GitHub Desktop.
test push nodes
This file contains 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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
init() { | |
this._super(...arguments); | |
let data = []; | |
let included = []; | |
let time = performance.now(); | |
for (let i = 0; i < 50000; i=i+8) { | |
data.push({ | |
id: i, | |
type: 'node', | |
attributes: { | |
name: `level ${i}` | |
}, | |
relationships: { | |
children: { | |
data: [{id: i+1, type: 'node'}] | |
} | |
} | |
}); | |
included.push(...[{ | |
id: i+1, | |
type: 'node', | |
attributes: { | |
name: `level ${i+1}` | |
}, | |
relationships: { | |
children: { | |
data: [{id: i+2, type: 'node'}, {id: i+3, type: 'node'}] | |
} | |
} | |
},{ | |
id: i+2, | |
type: 'node', | |
attributes: { | |
name: `level ${i+2}` | |
}, | |
relationships: { | |
children: { | |
data: [{id: i+4, type: 'node'}] | |
} | |
} | |
},{ | |
id: i+3, | |
type: 'node', | |
attributes: { | |
name: `level ${i+2}` | |
} | |
},{ | |
id: i+4, | |
type: 'node', | |
attributes: { | |
name: `level ${i+3}` | |
}, | |
relationships: { | |
children: { | |
data: [{id: i+5, type: 'node'}, {id: i+6, type: 'node'}] | |
} | |
} | |
},{ | |
id: i+5, | |
type: 'node', | |
attributes: { | |
name: `level ${i+4}` | |
} | |
},{ | |
id: i+6, | |
type: 'node', | |
attributes: { | |
name: `level ${i+4}` | |
} | |
}] | |
) | |
} | |
const model = this.store.push({data, included}); | |
this.set('time', performance.now() - time); | |
this.set('model', model); | |
} | |
}); |
This file contains 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
import Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
import { belongsTo, hasMany } from "ember-data/relationships"; | |
export default Model.extend({ | |
name: attr('string'), | |
children: hasMany('node', { async: false, inverse: null }) | |
}); |
This file contains 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
{ | |
"version": "0.13.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.16.2", | |
"ember-template-compiler": "2.16.2", | |
"ember-testing": "2.16.2" | |
}, | |
"addons": { | |
"ember-data": "2.16.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment