@onehat/data 1.4.1 → 1.4.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onehat/data",
3
- "version": "1.4.1",
3
+ "version": "1.4.5",
4
4
  "description": "JS data modeling package with adapters for many storage mediums.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/OneHatData.js CHANGED
@@ -282,12 +282,15 @@ export class OneHatData extends EventEmitter {
282
282
  if (this.isDestroyed) {
283
283
  throw new Error('this.createRepositories is no longer valid. OneHatData has been destroyed.');
284
284
  }
285
- let promises = [];
286
- _.each(schemas, (schema) => {
287
- promises.push( this.createRepository({ schema, }, bound) );
288
- });
289
-
290
- await Promise.all(promises);
285
+ const schemasArray = _.map(schemas, (schema) => schema);
286
+ let i, schema, repository;
287
+ for (i = 0; i < schemasArray.length; i++) {
288
+ schema = schemasArray[i];
289
+ repository = await this.createRepository({ schema, }, bound);
290
+ if (!repository) {
291
+ throw new Error('Repository could not be created');
292
+ }
293
+ }
291
294
  return this;
292
295
  }
293
296
 
@@ -4,6 +4,21 @@ import AjaxRepository from './Ajax';
4
4
  import qs from 'qs';
5
5
  import _ from 'lodash';
6
6
 
7
+ const nonConditionFilters = [
8
+ 'q',
9
+ 'hydrate',
10
+ 'fields',
11
+ 'distinct',
12
+ 'leftJoinWith',
13
+ 'join',
14
+ 'where',
15
+ 'matching',
16
+ 'contain',
17
+ 'order',
18
+ 'limit',
19
+ 'page',
20
+ ];
21
+
7
22
  /**
8
23
  * This class contains overrides of specific functions in
9
24
  * AjaxRepository that are unique to OneBuild.
@@ -129,12 +144,16 @@ class OneBuildRepository extends AjaxRepository {
129
144
  // Clear existing "conditions" params
130
145
  if (!_.isEmpty(this._params)) {
131
146
  this._params = _.omitBy(this._params, (value, key) => {
132
- return key.match(/^conditions/);
147
+ return key.match(/^conditions/) || _.includes(nonConditionFilters, key);
133
148
  });
134
149
  }
135
150
 
136
151
  _.each(this.filters, (filter, ix) => {
137
- this.setParam('conditions[' + filter.name + ']', filter.value);
152
+ if (_.includes(nonConditionFilters, filter.name)) {
153
+ this.setParam(filter.name, filter.value);
154
+ } else {
155
+ this.setParam('conditions[' + filter.name + ']', filter.value);
156
+ }
138
157
  });
139
158
 
140
159
  if (this.isLoaded) {