Created
November 28, 2019 11:50
-
-
Save PoslinskiNet/2a8d911d2c78f23c7bc8e7e739fc92e1 to your computer and use it in GitHub Desktop.
New Twiddle
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({ | |
actions: { | |
add() { | |
const { title, calories } = this; | |
this.db.recipes.add({ title, calories: parseInt(calories) }).then(() => { | |
this.db.table("recipes") | |
.orderBy("calories") | |
.toArray() | |
.then(recipes => { | |
this.set("model", recipes) | |
}); | |
}); | |
} | |
} | |
}); |
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'; | |
import Dexie from 'dexie'; | |
export default Ember.Route.extend({ | |
beforeModel() { | |
const db = new Dexie("recipes"); | |
db.version(1).stores({ | |
recipes: "++id,title,calories" | |
}); | |
this.set("db", db); | |
}, | |
model() { | |
return this.db.recipes.orderBy("calories").toArray(); | |
}, | |
setupController(controller, model) { | |
controller.set('db', this.db); | |
controller.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
{ | |
"version": "0.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3", | |
"dexie": "^2.0.4" | |
}, | |
"addons": { | |
"ember-data": "3.4.2", | |
"ember-auto-import": "^1.5.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment