Skip to content
Browse files

Get the example To-do app working with Model in-memory adapter

  • Loading branch information...
1 parent b4935c0 commit 52140ee690f722954e1c197a419d675cbaa1a859 mde committed
View
7 examples/todo_app/app/controllers/todos.js
@@ -4,7 +4,7 @@ var Todos = function () {
this.index = function (req, resp, params) {
var self = this;
- geddy.model.adapter.Todo.all(function(err, todos){
+ geddy.model.Todo.all(function(err, todos){
self.respond({params: params, todos: todos});
});
};
@@ -17,7 +17,6 @@ var Todos = function () {
var self = this
, todo = geddy.model.Todo.create({
title: params.title
- , id: geddy.string.uuid(10)
, status: 'open'
});
todo.save(function (err, data) {
@@ -33,7 +32,7 @@ var Todos = function () {
this.show = function (req, resp, params) {
var self = this;
- geddy.model.adapter.Todo.load(params.id, function(err, todo){
+ geddy.model.Todo.first(params.id, function(err, todo){
self.respond({params: params, todo: todo});
});
};
@@ -47,7 +46,7 @@ var Todos = function () {
this.update = function (req, resp, params) {
var self = this;
- geddy.model.adapter.Todo.load(params.id, function (err, todo) {
+ geddy.model.Todo.first(params.id, function (err, todo) {
todo.status = params.status;
todo.title = params.title;
todo.save(function (err, data) {
View
1 examples/todo_app/app/models/todo.js
@@ -3,7 +3,6 @@ var Todo = function () {
this.defineProperties({
title: {type: 'string', required: true}
- , id: {type: 'string', required: true}
, status: {type: 'string', required: true}
});
View
5 examples/todo_app/config/development.js
@@ -21,8 +21,11 @@ var config = {
, debug: true
, hostname: null
, port: 4000
+, model: {
+ defaultAdapter: 'memory'
+ }
, sessions: {
- store: 'memory'
+ store: 'cookie'
, key: 'sid'
, expiry: 14 * 24 * 60 * 60
}
View
2 examples/todo_app/config/environment.js
@@ -6,6 +6,8 @@ var config = {
};
+config.secret = 'lrgkqKg6fJxqPTjq7nkqWOthgbloVBD8ZTadsN4xTzoFlAQvCmSqD1Wvuuk8ijNh0cxgY84Xj7gn0WXQCkmggnyRNeN0Y3zfBuOWPJAaKATWTdQo4zuPdFmMtZX2dgNC';
+
module.exports = config;
View
1 lib/app.js
@@ -25,7 +25,6 @@ var fs = require('fs')
, cwd = process.cwd()
, errors = require('./response/errors')
, response = require('./response')
- , model = require('./model')
, utils = require('utilities')
, i18n = require('./i18n')
, init = require('./init')
View
5 lib/init/model.js
@@ -112,6 +112,11 @@ module.exports = new (function () {
adapter.connect();
}
model.loadedAdapters[adapterName] = adapter;
+ if (typeof adapter.createTable == 'function') {
+ // FIXME -- fire-and-forget bad, need to make this
+ // recursive
+ adapter.createTable(name, function () {});
+ }
}
model.adapters[name] = adapter;
}

0 comments on commit 52140ee

Please sign in to comment.
Something went wrong with that request. Please try again.