Skip to content

Commit cca1cbb

Browse files
committed
Not strict equal when matching ids in embedded lists
1 parent 4ce4a0b commit cca1cbb

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Feel free to vote and comment on cards (tickets/issues), if you want to join tea
1818

1919
```javascript
2020
var Schema = require('./jugglingdb').Schema;
21-
var schema = new Schema('redis', {port: 6379}); //port number depends on your configuration
21+
var schema = new Schema('redis2', {port: 6379}); //port number depends on your configuration
2222
// define models
2323
var Post = schema.define('Post', {
2424
title: { type: String, length: 255 },

lib/adapters/redis2.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,8 @@ BridgeToRedis.prototype.all = function all(model, filter, callback) {
427427

428428
// LIMIT
429429
if (filter.limit){
430-
var from = (filter.offset || 0), to = from + filter.limit;
431-
sortCmd.push("LIMIT", from, to);
430+
var offset = (filter.offset || 0), limit = filter.limit;
431+
sortCmd.push("LIMIT", offset, limit);
432432
}
433433

434434
// we need ALPHA modifier when sorting string values

lib/list.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,14 @@ List.prototype.push = function (obj) {
130130

131131
List.prototype.remove = function (obj) {
132132
var id = obj.id ? obj.id : obj;
133-
console.log(id);
134133
var found = false;
135134
this.items.forEach(function (o, i) {
136-
if (o.id === id) found = i;
135+
if (id && o.id == id) {
136+
found = i;
137+
if (o.id !== id) {
138+
console.log('WARNING! Type of id not matched');
139+
}
140+
}
137141
});
138142
if (found !== false) {
139143
delete this[id];

0 commit comments

Comments
 (0)