Skip to content

Commit 2bc5f44

Browse files
committed
bugfixes and additions:
- made backbone-redis.js work on server without sockets - added sorting solution - added foreign key solution
1 parent cc79e54 commit 2bc5f44

File tree

8 files changed

+660
-409
lines changed

8 files changed

+660
-409
lines changed

browser/backbone.redis.js

+141-105
Large diffs are not rendered by default.

browser/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// backbone-redis
1+
// Backbone-Redis
22
// (c) 2011 Beau Sorensen
3-
// backbone-redis may be freely distributed under the MIT license.
3+
// Backbone-Redis may be freely distributed under the MIT license.
44
// For all details and documentation:
55
// https://github.com/sorensen/backbone-redis
66

7-
module.exports = require('./backbone.redis');
7+
module.exports = require('./backbone-redis');

examples/todos/server.js

+13-79
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require.paths.unshift('../../lib');
66
// Project dependencies
77
var express = require('express'),
88
Redis = require('redis'),
9-
support = require('../../'),
9+
middleware = require('../../'),
1010
browserify = require('browserify'),
1111
io = require('socket.io'),
1212
server = module.exports = express.createServer(),
@@ -47,84 +47,18 @@ server.get('/', function(req, res) {
4747
res.render(__dirname + '/index.html');
4848
});
4949

50-
//db.flushall();
51-
52-
support.config({
53-
io : io,
54-
database : db,
55-
publish : pub,
56-
subscribe : sub,
57-
listener : 'backbone',
58-
safeMode : true,
59-
showDebug : true,
60-
showError : true
61-
});
62-
63-
64-
model = support
65-
.schema({
66-
content : '',
67-
order : '',
68-
done : ''
69-
})
70-
.pre('create', function(next, sock, data, cb) {
71-
console.log('todo-pre-create');
72-
next(sock, data, cb);
73-
})
74-
.pre('read', function(next, sock, data, cb) {
75-
console.log('todo-pre-read');
76-
next(sock, data, cb);
77-
})
78-
.pre('update', function(next, sock, data, cb) {
79-
console.log('todo-pre-update');
80-
next(sock, data, cb);
81-
})
82-
.pre('delete', function(next, sock, data, cb) {
83-
console.log('todo-pre-delete');
84-
next(sock, data, cb);
85-
})
86-
.pre('subscribe', function(next, sock, data, cb) {
87-
console.log('todo-pre-subscribe');
88-
next(sock, data, cb);
89-
})
90-
.pre('unsubscribe', function(next, sock, data, cb) {
91-
console.log('todo-pre-unsubscribe');
92-
next(sock, data, cb);
93-
})
94-
.pre('publish', function(next, sock, data, cb) {
95-
console.log('todo-pre-publish');
96-
next(sock, data, cb);
97-
})
98-
.post('create', function(next, sock, data, cb) {
99-
console.log('todo-post-create');
100-
next(sock, data, cb);
101-
})
102-
.post('read', function(next, sock, data, cb) {
103-
console.log('todo-post-read');
104-
next(sock, data, cb);
105-
})
106-
.post('update', function(next, sock, data, cb) {
107-
console.log('todo-post-update');
108-
next(sock, data, cb);
109-
})
110-
.post('delete', function(next, sock, data, cb) {
111-
console.log('todo-post-delete');
112-
next(sock, data, cb);
113-
})
114-
.post('subscribe', function(next, sock, data, cb) {
115-
console.log('todo-post-subscribe');
116-
next(sock, data, cb);
117-
})
118-
.post('unsubscribe', function(next, sock, data, cb) {
119-
console.log('todo-post-unsubscribe');
120-
next(sock, data, cb);
121-
})
122-
.post('publish', function(next, sock, data, cb) {
123-
console.log('todo-post-publish');
124-
next(sock, data, cb);
50+
// Start up the application
51+
if (!module.parent) {
52+
middleware({
53+
io : io,
54+
db : db,
55+
publish : pub,
56+
subscribe : sub,
57+
listener : 'backbone'
12558
});
12659

127-
support.model('todo', model);
128-
60+
middleware.pre('room:save', function(model, options, next) {
12961

130-
server.listen(8080);
62+
});
63+
server.listen(8080);
64+
}

examples/todos/todos.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ $(function(){
2626
// Default attributes for the todo.
2727
defaults: {
2828
content: "empty todo...",
29-
done: false,
30-
dirty: "dirty data",
29+
done: false
3130
},
3231

3332
// Ensure that each todo created has `content`.

index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// backbone-redis
1+
// Backbone-Redis
22
// (c) 2011 Beau Sorensen
3-
// backbone-redis may be freely distributed under the MIT license.
3+
// Backbone-Redis may be freely distributed under the MIT license.
44
// For all details and documentation:
55
// https://github.com/sorensen/backbone-redis
66

0 commit comments

Comments
 (0)