react-native-onyx 3.0.90 → 3.0.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -150,10 +150,17 @@ const provider = {
150
150
  if (!provider.store) {
151
151
  throw new Error('Store is not initialized!');
152
152
  }
153
- return provider.store.executeAsync('SELECT record_key, valueJSON FROM keyvaluepairs;').then(({ rows }) => {
154
- // eslint-disable-next-line no-underscore-dangle
155
- const result = rows === null || rows === void 0 ? void 0 : rows._array.map((row) => [row.record_key, JSON.parse(row.valueJSON)]);
156
- return (result !== null && result !== void 0 ? result : []);
153
+ // Aggregate the whole table into a single JSON string in SQLite so we only run JSON.parse
154
+ // once, instead of returning every row and parsing each one individually in JavaScript.
155
+ return provider.store
156
+ .executeAsync('SELECT json_group_array(json_array(record_key, json(valueJSON))) AS aggregated FROM keyvaluepairs;')
157
+ .then(({ rows }) => {
158
+ var _a;
159
+ const aggregated = (_a = rows === null || rows === void 0 ? void 0 : rows.item(0)) === null || _a === void 0 ? void 0 : _a.aggregated;
160
+ if (aggregated == null) {
161
+ return [];
162
+ }
163
+ return JSON.parse(aggregated);
157
164
  });
158
165
  },
159
166
  removeItem(key) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-onyx",
3
- "version": "3.0.90",
3
+ "version": "3.0.91",
4
4
  "author": "Expensify, Inc.",
5
5
  "homepage": "https://expensify.com",
6
6
  "description": "State management for React Native",