Permalink
Browse files

Not strict equal when matching ids in embedded lists

  • Loading branch information...
1 parent 4ce4a0b commit cca1cbb3f8655dfc7c91392f87ebfd8b92e7014c @1602 committed Sep 20, 2012
Showing with 9 additions and 5 deletions.
  1. +1 −1 README.md
  2. +2 −2 lib/adapters/redis2.js
  3. +6 −2 lib/list.js
View
@@ -18,7 +18,7 @@ Feel free to vote and comment on cards (tickets/issues), if you want to join tea
```javascript
var Schema = require('./jugglingdb').Schema;
-var schema = new Schema('redis', {port: 6379}); //port number depends on your configuration
+var schema = new Schema('redis2', {port: 6379}); //port number depends on your configuration
// define models
var Post = schema.define('Post', {
title: { type: String, length: 255 },
View
@@ -427,8 +427,8 @@ BridgeToRedis.prototype.all = function all(model, filter, callback) {
// LIMIT
if (filter.limit){
- var from = (filter.offset || 0), to = from + filter.limit;
- sortCmd.push("LIMIT", from, to);
+ var offset = (filter.offset || 0), limit = filter.limit;
+ sortCmd.push("LIMIT", offset, limit);
}
// we need ALPHA modifier when sorting string values
View
@@ -130,10 +130,14 @@ List.prototype.push = function (obj) {
List.prototype.remove = function (obj) {
var id = obj.id ? obj.id : obj;
- console.log(id);
var found = false;
this.items.forEach(function (o, i) {
- if (o.id === id) found = i;
+ if (id && o.id == id) {
+ found = i;
+ if (o.id !== id) {
+ console.log('WARNING! Type of id not matched');
+ }
+ }
});
if (found !== false) {
delete this[id];

0 comments on commit cca1cbb

Please sign in to comment.