Changeset 8886
- Timestamp:
- 04/29/08 16:07:10 (4 months ago)
- Files:
-
- sandbox/minibase/trunk/demo/main.js (modified) (2 diffs)
- sandbox/minibase/trunk/demo/model.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/minibase/trunk/demo/main.js
r8884 r8886 10 10 var books = model.Book.all(); 11 11 if (req.data.save) { 12 var book = new model.Book({author: req.data.author, title: req.data.title}); 13 book.save(); 14 res.redirect('/'); 12 createBook(); 15 13 } 16 14 if (req.data.remove) { 17 var book = model.Book.get(req.data.remove); 18 book.remove(); 19 res.redirect('/'); 15 removeBook(); 20 16 } 21 17 renderSkin('skins/index.html', { … … 30 26 } 31 27 28 function createBook() { 29 var book = new model.Book({author: req.data.author, title: req.data.title}); 30 book.save(); 31 res.redirect('/'); 32 } 33 34 function removeBook() { 35 var book = model.Book.get(req.data.remove); 36 book.remove(); 37 res.redirect('/'); 38 } 39 32 40 function getDeleteLink(book) { 33 41 return '<a href="/?remove=' + book._id + '">delete</a>'; sandbox/minibase/trunk/demo/model.js
r8884 r8886 3 3 4 4 /** 5 * Our model class 5 * Our model class. The only thing to observe is to return a Storable 6 * instance, passing this object and an object containing the persistent 7 * properties to the Storable constructor. 8 * 6 9 * @param properties persistent properties container 7 10 */ … … 12 15 } 13 16 14 return new db.Storable(this, properties );17 return new db.Storable(this, properties || {}); 15 18 } 16 19 20 // init store instance and register persistent classes 17 21 db.store = db.store || new db.Store("db"); 18 22 db.store.registerType(Book);