Skip to content

Commit

Permalink
improve orbit db index api to read RR list
Browse files Browse the repository at this point in the history
  • Loading branch information
fazo96 committed Jun 6, 2018
1 parent da60979 commit 548fe60
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/modules/orbitdb/abstract.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class ChluAbstractIndex {
return this._getLatestReviewRecordUpdate(multihash) || multihash;
}

getReviewRecordList() {
return this._getReviewRecordList();
getReviewRecordList(offset = 0, limit = 0) {
return this._getReviewRecordList(offset, limit);
}

getOriginalReviewRecord(updatedMultihash) {
Expand All @@ -70,6 +70,10 @@ class ChluAbstractIndex {
return this._getReviewRecordMetadata(multihash);
}

getReviewRecordCount() {
return this._getReviewRecordCount();
}

_addOriginalReviewRecord() {
notImplemented();
}
Expand All @@ -94,6 +98,10 @@ class ChluAbstractIndex {
notImplemented();
}

_getReviewRecordCount() {
notImplemented();
}

}

function notImplemented() {
Expand Down
9 changes: 6 additions & 3 deletions src/modules/orbitdb/inmemory.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ class ChluInMemoryIndex extends ChluAbstractIndex {
return this._index.data[multihash] || null;
}

_getReviewRecordList() {
// Clone array
return [ ...this._index.list ];
_getReviewRecordList(offset, limit) {
return this._index.list.slice(offset, (limit > 0 ? (offset + limit) : undefined));
}

_getReviewRecordCount() {
return this._index.list.length;
}

}
Expand Down

0 comments on commit 548fe60

Please sign in to comment.