Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

refactor: getItems should return an object intead of an array

thecodrr0421c9c45296
diff --git a/packages/core/collections/content.js b/packages/core/collections/content.js
index 767e45c9c..8bca906a7 100644
--- a/packages/core/collections/content.js
+++ b/packages/core/collections/content.js
@@ -58,8 +58,10 @@ export default class Content extends Collection {
return this._collection.getItems(ids);
}
- all() {
- return this._collection.getItems(this._collection.indexer.indices);
+ async all() {
+ return Object.values(
+ await this._collection.getItems(this._collection.indexer.indices)
+ );
}
insertMedia(contentItem) {
diff --git a/packages/core/database/indexed-collection.js b/packages/core/database/indexed-collection.js
index 2a82f75fa..23b8cfc79 100644
--- a/packages/core/database/indexed-collection.js
+++ b/packages/core/database/indexed-collection.js
@@ -64,9 +64,6 @@ export default class IndexedCollection {
async getItems(indices) {
const data = await this.indexer.readMulti(indices);
- return data.reduce((total, current) => {
- total.push(current[1]);
- return total;
- }, []);
+ return Object.fromEntries(data);
}
}