@statezero/core 0.1.60 → 0.1.61

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.
@@ -54,14 +54,7 @@ export class Manager {
54
54
  * @returns {Promise<Model>} A promise that resolves to the model instance.
55
55
  */
56
56
  async get(filters, serializerOptions) {
57
- let querySet = this.newQuerySet();
58
- if (filters) {
59
- querySet = querySet.filter(filters);
60
- }
61
- if (serializerOptions) {
62
- querySet.setSerializerOptions(serializerOptions);
63
- }
64
- return await QueryExecutor.execute(querySet, 'get');
57
+ return this.newQuerySet().get(filters, serializerOptions);
65
58
  }
66
59
  /**
67
60
  * Filters the QuerySet based on the provided conditions.
@@ -168,7 +161,7 @@ export class Manager {
168
161
  * @returns {Promise<*>} A promise that resolves to the newly created model instance.
169
162
  */
170
163
  async create(data) {
171
- return await QueryExecutor.execute(this.newQuerySet(), 'create', { data });
164
+ return this.newQuerySet().create(data);
172
165
  }
173
166
  /**
174
167
  * Fetches all records using the current QuerySet.
@@ -177,11 +170,7 @@ export class Manager {
177
170
  * @returns {Promise<Array<*>>} A promise that resolves to an array of model instances.
178
171
  */
179
172
  async fetch(serializerOptions) {
180
- const querySet = this.newQuerySet();
181
- if (serializerOptions) {
182
- querySet.setSerializerOptions(serializerOptions);
183
- }
184
- return await QueryExecutor.execute(querySet, 'list');
173
+ return this.newQuerySet().fetch(serializerOptions);
185
174
  }
186
175
  /**
187
176
  * Retrieves or creates a model instance based on lookup fields and defaults.
@@ -194,7 +183,7 @@ export class Manager {
194
183
  */
195
184
  async getOrCreate(lookupFields, options = {}) {
196
185
  const { defaults = {} } = options;
197
- return await QueryExecutor.execute(this.newQuerySet(), 'get_or_create', { lookup: lookupFields, defaults });
186
+ return this.newQuerySet().getOrCreate(lookupFields, defaults);
198
187
  }
199
188
  /**
200
189
  * Updates or creates a model instance based on lookup fields and defaults.
@@ -207,7 +196,7 @@ export class Manager {
207
196
  */
208
197
  async updateOrCreate(lookupFields, options = {}) {
209
198
  const { defaults = {} } = options;
210
- return await QueryExecutor.execute(this.newQuerySet(), 'update_or_create', { lookup: lookupFields, defaults });
199
+ return this.newQuerySet().updateOrCreate(lookupFields, defaults);
211
200
  }
212
201
  /**
213
202
  * Applies a search to the QuerySet using the specified search query and fields.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statezero/core",
3
- "version": "0.1.60",
3
+ "version": "0.1.61",
4
4
  "type": "module",
5
5
  "module": "ESNext",
6
6
  "description": "The type-safe frontend client for StateZero - connect directly to your backend models with zero boilerplate",