@statezero/core 0.2.4 → 0.2.6
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/dist/cli/commands/syncModels.js +9 -0
- package/dist/flavours/django/manager.d.ts +4 -10
- package/dist/flavours/django/manager.js +4 -8
- package/dist/flavours/django/model.d.ts +2 -1
- package/dist/flavours/django/model.js +9 -1
- package/dist/models/backend1/django_app/comprehensivemodel.js +8 -0
- package/dist/models/backend1/django_app/custompkmodel.js +8 -0
- package/dist/models/backend1/django_app/dailyrate.d.ts +47 -0
- package/dist/models/backend1/django_app/dailyrate.js +71 -0
- package/dist/models/backend1/django_app/deepmodellevel1.js +8 -0
- package/dist/models/backend1/django_app/deepmodellevel2.js +8 -0
- package/dist/models/backend1/django_app/deepmodellevel3.js +8 -0
- package/dist/models/backend1/django_app/dummymodel.js +8 -0
- package/dist/models/backend1/django_app/dummyrelatedmodel.js +8 -0
- package/dist/models/backend1/django_app/filetest.js +8 -0
- package/dist/models/backend1/django_app/index.d.ts +2 -0
- package/dist/models/backend1/django_app/index.js +2 -0
- package/dist/models/backend1/django_app/modelwithcustompkrelation.js +8 -0
- package/dist/models/backend1/django_app/namefiltercustompkmodel.js +8 -0
- package/dist/models/backend1/django_app/order.js +8 -0
- package/dist/models/backend1/django_app/orderitem.js +8 -0
- package/dist/models/backend1/django_app/product.js +8 -0
- package/dist/models/backend1/django_app/productcategory.js +8 -0
- package/dist/models/backend1/django_app/rateplan.d.ts +44 -0
- package/dist/models/backend1/django_app/rateplan.js +69 -0
- package/dist/models/default/django_app/comprehensivemodel.js +8 -0
- package/dist/models/default/django_app/custompkmodel.js +8 -0
- package/dist/models/default/django_app/dailyrate.d.ts +47 -0
- package/dist/models/default/django_app/dailyrate.js +71 -0
- package/dist/models/default/django_app/deepmodellevel1.js +8 -0
- package/dist/models/default/django_app/deepmodellevel2.js +8 -0
- package/dist/models/default/django_app/deepmodellevel3.js +8 -0
- package/dist/models/default/django_app/dummymodel.js +8 -0
- package/dist/models/default/django_app/dummyrelatedmodel.js +8 -0
- package/dist/models/default/django_app/filetest.js +8 -0
- package/dist/models/default/django_app/index.d.ts +2 -0
- package/dist/models/default/django_app/index.js +2 -0
- package/dist/models/default/django_app/modelwithcustompkrelation.js +8 -0
- package/dist/models/default/django_app/namefiltercustompkmodel.js +8 -0
- package/dist/models/default/django_app/order.js +8 -0
- package/dist/models/default/django_app/orderitem.js +8 -0
- package/dist/models/default/django_app/product.js +8 -0
- package/dist/models/default/django_app/productcategory.js +8 -0
- package/dist/models/default/django_app/rateplan.d.ts +44 -0
- package/dist/models/default/django_app/rateplan.js +69 -0
- package/dist/syncEngine/stores/modelStore.js +2 -1
- package/package.json +1 -1
- package/readme.md +1 -1
|
@@ -226,6 +226,15 @@ export class {{className}} extends Model {
|
|
|
226
226
|
configurable: true
|
|
227
227
|
});
|
|
228
228
|
});
|
|
229
|
+
|
|
230
|
+
// Add a special read-only getter for the repr field
|
|
231
|
+
Object.defineProperty(this, 'repr', {
|
|
232
|
+
get: function() {
|
|
233
|
+
return this.getField('repr');
|
|
234
|
+
},
|
|
235
|
+
enumerable: true, // Make sure repr is enumerable
|
|
236
|
+
configurable: true
|
|
237
|
+
});
|
|
229
238
|
}
|
|
230
239
|
}
|
|
231
240
|
`;
|
|
@@ -137,26 +137,20 @@ export class Manager {
|
|
|
137
137
|
* Retrieves or creates a model instance based on lookup fields and defaults.
|
|
138
138
|
*
|
|
139
139
|
* @param {*} lookupFields - The fields to lookup the model.
|
|
140
|
-
* @param {Object} [
|
|
141
|
-
* @param {*} [options.defaults={}] - Default values to use when creating a new instance.
|
|
140
|
+
* @param {Object} [defaults={}] - Default values to use when creating a new instance.
|
|
142
141
|
* @returns {Promise<ResultTuple>} A promise that resolves to a ResultTuple containing the model instance
|
|
143
142
|
* and a boolean indicating whether it was created.
|
|
144
143
|
*/
|
|
145
|
-
getOrCreate(lookupFields: any,
|
|
146
|
-
defaults?: any;
|
|
147
|
-
}): Promise<ResultTuple>;
|
|
144
|
+
getOrCreate(lookupFields: any, defaults?: Object): Promise<ResultTuple>;
|
|
148
145
|
/**
|
|
149
146
|
* Updates or creates a model instance based on lookup fields and defaults.
|
|
150
147
|
*
|
|
151
148
|
* @param {*} lookupFields - The fields to lookup the model.
|
|
152
|
-
* @param {Object} [
|
|
153
|
-
* @param {*} [options.defaults={}] - Default values to use when updating or creating the instance.
|
|
149
|
+
* @param {Object} [defaults={}] - Default values to use when updating or creating the instance.
|
|
154
150
|
* @returns {Promise<ResultTuple>} A promise that resolves to a ResultTuple containing the model instance
|
|
155
151
|
* and a boolean indicating whether it was created.
|
|
156
152
|
*/
|
|
157
|
-
updateOrCreate(lookupFields: any,
|
|
158
|
-
defaults?: any;
|
|
159
|
-
}): Promise<ResultTuple>;
|
|
153
|
+
updateOrCreate(lookupFields: any, defaults?: Object): Promise<ResultTuple>;
|
|
160
154
|
/**
|
|
161
155
|
* Applies a search to the QuerySet using the specified search query and fields.
|
|
162
156
|
*
|
|
@@ -174,26 +174,22 @@ export class Manager {
|
|
|
174
174
|
* Retrieves or creates a model instance based on lookup fields and defaults.
|
|
175
175
|
*
|
|
176
176
|
* @param {*} lookupFields - The fields to lookup the model.
|
|
177
|
-
* @param {Object} [
|
|
178
|
-
* @param {*} [options.defaults={}] - Default values to use when creating a new instance.
|
|
177
|
+
* @param {Object} [defaults={}] - Default values to use when creating a new instance.
|
|
179
178
|
* @returns {Promise<ResultTuple>} A promise that resolves to a ResultTuple containing the model instance
|
|
180
179
|
* and a boolean indicating whether it was created.
|
|
181
180
|
*/
|
|
182
|
-
async getOrCreate(lookupFields,
|
|
183
|
-
const { defaults = {} } = options;
|
|
181
|
+
async getOrCreate(lookupFields, defaults = {}) {
|
|
184
182
|
return this.newQuerySet().getOrCreate(lookupFields, defaults);
|
|
185
183
|
}
|
|
186
184
|
/**
|
|
187
185
|
* Updates or creates a model instance based on lookup fields and defaults.
|
|
188
186
|
*
|
|
189
187
|
* @param {*} lookupFields - The fields to lookup the model.
|
|
190
|
-
* @param {Object} [
|
|
191
|
-
* @param {*} [options.defaults={}] - Default values to use when updating or creating the instance.
|
|
188
|
+
* @param {Object} [defaults={}] - Default values to use when updating or creating the instance.
|
|
192
189
|
* @returns {Promise<ResultTuple>} A promise that resolves to a ResultTuple containing the model instance
|
|
193
190
|
* and a boolean indicating whether it was created.
|
|
194
191
|
*/
|
|
195
|
-
async updateOrCreate(lookupFields,
|
|
196
|
-
const { defaults = {} } = options;
|
|
192
|
+
async updateOrCreate(lookupFields, defaults = {}) {
|
|
197
193
|
return this.newQuerySet().updateOrCreate(lookupFields, defaults);
|
|
198
194
|
}
|
|
199
195
|
/**
|
|
@@ -91,9 +91,10 @@ export class Model {
|
|
|
91
91
|
* By default, it returns all enumerable own properties.
|
|
92
92
|
* Subclasses should override this to return specific keys.
|
|
93
93
|
*
|
|
94
|
+
* @param {boolean} includeRepr - Whether to include the repr field (for caching). Default: false.
|
|
94
95
|
* @returns {Object} The serialized model data.
|
|
95
96
|
*/
|
|
96
|
-
serialize(): Object;
|
|
97
|
+
serialize(includeRepr?: boolean): Object;
|
|
97
98
|
/**
|
|
98
99
|
* Saves the model instance by either creating a new record or updating an existing one.
|
|
99
100
|
*
|
|
@@ -140,9 +140,10 @@ export class Model {
|
|
|
140
140
|
* By default, it returns all enumerable own properties.
|
|
141
141
|
* Subclasses should override this to return specific keys.
|
|
142
142
|
*
|
|
143
|
+
* @param {boolean} includeRepr - Whether to include the repr field (for caching). Default: false.
|
|
143
144
|
* @returns {Object} The serialized model data.
|
|
144
145
|
*/
|
|
145
|
-
serialize() {
|
|
146
|
+
serialize(includeRepr = false) {
|
|
146
147
|
const ModelClass = this.constructor;
|
|
147
148
|
const data = {};
|
|
148
149
|
// Collect all field values (already in internal format)
|
|
@@ -162,6 +163,13 @@ export class Model {
|
|
|
162
163
|
data[field] = value;
|
|
163
164
|
}
|
|
164
165
|
}
|
|
166
|
+
// Include repr field if requested (for caching purposes)
|
|
167
|
+
if (includeRepr && !isNil(this._pk)) {
|
|
168
|
+
const storedData = modelStoreRegistry.getEntity(ModelClass, this._pk);
|
|
169
|
+
if (storedData && storedData.repr) {
|
|
170
|
+
data.repr = storedData.repr;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
165
173
|
// Data is already in internal format, so return as-is for API transmission
|
|
166
174
|
return data;
|
|
167
175
|
}
|
|
@@ -49,6 +49,14 @@ export class ComprehensiveModel extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class CustomPKModel extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-specific QuerySet implementation
|
|
3
|
+
*/
|
|
4
|
+
export class DailyRateQuerySet extends QuerySet<any> {
|
|
5
|
+
constructor(ModelClass: ModelConstructor, config?: {
|
|
6
|
+
nodes?: QueryNode[] | undefined;
|
|
7
|
+
orderBy?: {
|
|
8
|
+
field: string;
|
|
9
|
+
direction: "asc" | "desc";
|
|
10
|
+
}[] | undefined;
|
|
11
|
+
fields?: Set<string> | undefined;
|
|
12
|
+
aggregations?: Aggregation[] | undefined;
|
|
13
|
+
initialQueryset?: string | undefined;
|
|
14
|
+
serializerOptions?: SerializerOptions;
|
|
15
|
+
materialized?: boolean | undefined;
|
|
16
|
+
} | undefined, parent?: null);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Model-specific Manager implementation
|
|
20
|
+
*/
|
|
21
|
+
export class DailyRateManager extends Manager {
|
|
22
|
+
constructor(ModelClass: any);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Implementation of the DailyRate model
|
|
26
|
+
*/
|
|
27
|
+
export class DailyRate extends Model {
|
|
28
|
+
static configKey: string;
|
|
29
|
+
static modelName: string;
|
|
30
|
+
static primaryKeyField: string;
|
|
31
|
+
static objects: DailyRateManager;
|
|
32
|
+
static fields: string[];
|
|
33
|
+
static schema: any;
|
|
34
|
+
static relationshipFields: Map<string, {
|
|
35
|
+
ModelClass: () => Function | null;
|
|
36
|
+
relationshipType: string;
|
|
37
|
+
}>;
|
|
38
|
+
constructor(data: any);
|
|
39
|
+
/**
|
|
40
|
+
* Define property getters and setters for all model fields
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
private _defineProperties;
|
|
44
|
+
}
|
|
45
|
+
import { QuerySet } from '../../../../src';
|
|
46
|
+
import { Manager } from '../../../../src';
|
|
47
|
+
import { Model } from '../../../../src';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated. Do not make direct changes to the file.
|
|
3
|
+
*/
|
|
4
|
+
import { Model, Manager, QuerySet, getModelClass } from '../../../../src';
|
|
5
|
+
import { wrapReactiveModel } from '../../../../src';
|
|
6
|
+
import schemaData from './dailyrate.schema.json';
|
|
7
|
+
/**
|
|
8
|
+
* Model-specific QuerySet implementation
|
|
9
|
+
*/
|
|
10
|
+
export class DailyRateQuerySet extends QuerySet {
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Model-specific Manager implementation
|
|
14
|
+
*/
|
|
15
|
+
export class DailyRateManager extends Manager {
|
|
16
|
+
constructor(ModelClass) {
|
|
17
|
+
super(ModelClass, DailyRateQuerySet);
|
|
18
|
+
}
|
|
19
|
+
newQuerySet() {
|
|
20
|
+
return new DailyRateQuerySet(this.ModelClass);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Implementation of the DailyRate model
|
|
25
|
+
*/
|
|
26
|
+
export class DailyRate extends Model {
|
|
27
|
+
constructor(data) {
|
|
28
|
+
DailyRate.validateFields(data);
|
|
29
|
+
super(data);
|
|
30
|
+
// Define getters and setters for all fields
|
|
31
|
+
this._defineProperties();
|
|
32
|
+
return wrapReactiveModel(this);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Define property getters and setters for all model fields
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
_defineProperties() {
|
|
39
|
+
// For each field, define a property that gets/sets from internal storage
|
|
40
|
+
DailyRate.fields.forEach(field => {
|
|
41
|
+
Object.defineProperty(this, field, {
|
|
42
|
+
get: function () {
|
|
43
|
+
return this.getField(field);
|
|
44
|
+
},
|
|
45
|
+
set: function (value) {
|
|
46
|
+
this.setField(field, value);
|
|
47
|
+
},
|
|
48
|
+
enumerable: true, // Make sure fields are enumerable for serialization
|
|
49
|
+
configurable: true
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Bind this model to its backend
|
|
63
|
+
DailyRate.configKey = 'backend1';
|
|
64
|
+
DailyRate.modelName = 'django_app.dailyrate';
|
|
65
|
+
DailyRate.primaryKeyField = 'id';
|
|
66
|
+
DailyRate.objects = new DailyRateManager(DailyRate);
|
|
67
|
+
DailyRate.fields = ['id', 'rate_plan', 'date', 'price', 'min_stay_arrival', 'min_stay_through', 'max_stay', 'closed_to_arrival', 'closed_to_departure', 'stop_sell'];
|
|
68
|
+
DailyRate.schema = schemaData;
|
|
69
|
+
DailyRate.relationshipFields = new Map([
|
|
70
|
+
['rate_plan', { 'ModelClass': () => getModelClass('django_app.rateplan', 'backend1'), 'relationshipType': 'foreign-key' }]
|
|
71
|
+
]);
|
|
@@ -49,6 +49,14 @@ export class DeepModelLevel1 extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class DeepModelLevel2 extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class DeepModelLevel3 extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class DummyModel extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class DummyRelatedModel extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class FileTest extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class ModelWithCustomPKRelation extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class NameFilterCustomPKModel extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class Order extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class OrderItem extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class Product extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class ProductCategory extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-specific QuerySet implementation
|
|
3
|
+
*/
|
|
4
|
+
export class RatePlanQuerySet extends QuerySet<any> {
|
|
5
|
+
constructor(ModelClass: ModelConstructor, config?: {
|
|
6
|
+
nodes?: QueryNode[] | undefined;
|
|
7
|
+
orderBy?: {
|
|
8
|
+
field: string;
|
|
9
|
+
direction: "asc" | "desc";
|
|
10
|
+
}[] | undefined;
|
|
11
|
+
fields?: Set<string> | undefined;
|
|
12
|
+
aggregations?: Aggregation[] | undefined;
|
|
13
|
+
initialQueryset?: string | undefined;
|
|
14
|
+
serializerOptions?: SerializerOptions;
|
|
15
|
+
materialized?: boolean | undefined;
|
|
16
|
+
} | undefined, parent?: null);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Model-specific Manager implementation
|
|
20
|
+
*/
|
|
21
|
+
export class RatePlanManager extends Manager {
|
|
22
|
+
constructor(ModelClass: any);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Implementation of the RatePlan model
|
|
26
|
+
*/
|
|
27
|
+
export class RatePlan extends Model {
|
|
28
|
+
static configKey: string;
|
|
29
|
+
static modelName: string;
|
|
30
|
+
static primaryKeyField: string;
|
|
31
|
+
static objects: RatePlanManager;
|
|
32
|
+
static fields: string[];
|
|
33
|
+
static schema: any;
|
|
34
|
+
static relationshipFields: Map<any, any>;
|
|
35
|
+
constructor(data: any);
|
|
36
|
+
/**
|
|
37
|
+
* Define property getters and setters for all model fields
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
private _defineProperties;
|
|
41
|
+
}
|
|
42
|
+
import { QuerySet } from '../../../../src';
|
|
43
|
+
import { Manager } from '../../../../src';
|
|
44
|
+
import { Model } from '../../../../src';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated. Do not make direct changes to the file.
|
|
3
|
+
*/
|
|
4
|
+
import { Model, Manager, QuerySet, getModelClass } from '../../../../src';
|
|
5
|
+
import { wrapReactiveModel } from '../../../../src';
|
|
6
|
+
import schemaData from './rateplan.schema.json';
|
|
7
|
+
/**
|
|
8
|
+
* Model-specific QuerySet implementation
|
|
9
|
+
*/
|
|
10
|
+
export class RatePlanQuerySet extends QuerySet {
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Model-specific Manager implementation
|
|
14
|
+
*/
|
|
15
|
+
export class RatePlanManager extends Manager {
|
|
16
|
+
constructor(ModelClass) {
|
|
17
|
+
super(ModelClass, RatePlanQuerySet);
|
|
18
|
+
}
|
|
19
|
+
newQuerySet() {
|
|
20
|
+
return new RatePlanQuerySet(this.ModelClass);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Implementation of the RatePlan model
|
|
25
|
+
*/
|
|
26
|
+
export class RatePlan extends Model {
|
|
27
|
+
constructor(data) {
|
|
28
|
+
RatePlan.validateFields(data);
|
|
29
|
+
super(data);
|
|
30
|
+
// Define getters and setters for all fields
|
|
31
|
+
this._defineProperties();
|
|
32
|
+
return wrapReactiveModel(this);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Define property getters and setters for all model fields
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
_defineProperties() {
|
|
39
|
+
// For each field, define a property that gets/sets from internal storage
|
|
40
|
+
RatePlan.fields.forEach(field => {
|
|
41
|
+
Object.defineProperty(this, field, {
|
|
42
|
+
get: function () {
|
|
43
|
+
return this.getField(field);
|
|
44
|
+
},
|
|
45
|
+
set: function (value) {
|
|
46
|
+
this.setField(field, value);
|
|
47
|
+
},
|
|
48
|
+
enumerable: true, // Make sure fields are enumerable for serialization
|
|
49
|
+
configurable: true
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Bind this model to its backend
|
|
63
|
+
RatePlan.configKey = 'backend1';
|
|
64
|
+
RatePlan.modelName = 'django_app.rateplan';
|
|
65
|
+
RatePlan.primaryKeyField = 'id';
|
|
66
|
+
RatePlan.objects = new RatePlanManager(RatePlan);
|
|
67
|
+
RatePlan.fields = ['id', 'name'];
|
|
68
|
+
RatePlan.schema = schemaData;
|
|
69
|
+
RatePlan.relationshipFields = new Map([]);
|
|
@@ -49,6 +49,14 @@ export class ComprehensiveModel extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class CustomPKModel extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-specific QuerySet implementation
|
|
3
|
+
*/
|
|
4
|
+
export class DailyRateQuerySet extends QuerySet<any> {
|
|
5
|
+
constructor(ModelClass: ModelConstructor, config?: {
|
|
6
|
+
nodes?: QueryNode[] | undefined;
|
|
7
|
+
orderBy?: {
|
|
8
|
+
field: string;
|
|
9
|
+
direction: "asc" | "desc";
|
|
10
|
+
}[] | undefined;
|
|
11
|
+
fields?: Set<string> | undefined;
|
|
12
|
+
aggregations?: Aggregation[] | undefined;
|
|
13
|
+
initialQueryset?: string | undefined;
|
|
14
|
+
serializerOptions?: SerializerOptions;
|
|
15
|
+
materialized?: boolean | undefined;
|
|
16
|
+
} | undefined, parent?: null);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Model-specific Manager implementation
|
|
20
|
+
*/
|
|
21
|
+
export class DailyRateManager extends Manager {
|
|
22
|
+
constructor(ModelClass: any);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Implementation of the DailyRate model
|
|
26
|
+
*/
|
|
27
|
+
export class DailyRate extends Model {
|
|
28
|
+
static configKey: string;
|
|
29
|
+
static modelName: string;
|
|
30
|
+
static primaryKeyField: string;
|
|
31
|
+
static objects: DailyRateManager;
|
|
32
|
+
static fields: string[];
|
|
33
|
+
static schema: any;
|
|
34
|
+
static relationshipFields: Map<string, {
|
|
35
|
+
ModelClass: () => Function | null;
|
|
36
|
+
relationshipType: string;
|
|
37
|
+
}>;
|
|
38
|
+
constructor(data: any);
|
|
39
|
+
/**
|
|
40
|
+
* Define property getters and setters for all model fields
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
private _defineProperties;
|
|
44
|
+
}
|
|
45
|
+
import { QuerySet } from '../../../../src';
|
|
46
|
+
import { Manager } from '../../../../src';
|
|
47
|
+
import { Model } from '../../../../src';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated. Do not make direct changes to the file.
|
|
3
|
+
*/
|
|
4
|
+
import { Model, Manager, QuerySet, getModelClass } from '../../../../src';
|
|
5
|
+
import { wrapReactiveModel } from '../../../../src';
|
|
6
|
+
import schemaData from './dailyrate.schema.json';
|
|
7
|
+
/**
|
|
8
|
+
* Model-specific QuerySet implementation
|
|
9
|
+
*/
|
|
10
|
+
export class DailyRateQuerySet extends QuerySet {
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Model-specific Manager implementation
|
|
14
|
+
*/
|
|
15
|
+
export class DailyRateManager extends Manager {
|
|
16
|
+
constructor(ModelClass) {
|
|
17
|
+
super(ModelClass, DailyRateQuerySet);
|
|
18
|
+
}
|
|
19
|
+
newQuerySet() {
|
|
20
|
+
return new DailyRateQuerySet(this.ModelClass);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Implementation of the DailyRate model
|
|
25
|
+
*/
|
|
26
|
+
export class DailyRate extends Model {
|
|
27
|
+
constructor(data) {
|
|
28
|
+
DailyRate.validateFields(data);
|
|
29
|
+
super(data);
|
|
30
|
+
// Define getters and setters for all fields
|
|
31
|
+
this._defineProperties();
|
|
32
|
+
return wrapReactiveModel(this);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Define property getters and setters for all model fields
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
_defineProperties() {
|
|
39
|
+
// For each field, define a property that gets/sets from internal storage
|
|
40
|
+
DailyRate.fields.forEach(field => {
|
|
41
|
+
Object.defineProperty(this, field, {
|
|
42
|
+
get: function () {
|
|
43
|
+
return this.getField(field);
|
|
44
|
+
},
|
|
45
|
+
set: function (value) {
|
|
46
|
+
this.setField(field, value);
|
|
47
|
+
},
|
|
48
|
+
enumerable: true, // Make sure fields are enumerable for serialization
|
|
49
|
+
configurable: true
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Bind this model to its backend
|
|
63
|
+
DailyRate.configKey = 'default';
|
|
64
|
+
DailyRate.modelName = 'django_app.dailyrate';
|
|
65
|
+
DailyRate.primaryKeyField = 'id';
|
|
66
|
+
DailyRate.objects = new DailyRateManager(DailyRate);
|
|
67
|
+
DailyRate.fields = ['id', 'rate_plan', 'date', 'price', 'min_stay_arrival', 'min_stay_through', 'max_stay', 'closed_to_arrival', 'closed_to_departure', 'stop_sell'];
|
|
68
|
+
DailyRate.schema = schemaData;
|
|
69
|
+
DailyRate.relationshipFields = new Map([
|
|
70
|
+
['rate_plan', { 'ModelClass': () => getModelClass('django_app.rateplan', 'default'), 'relationshipType': 'foreign-key' }]
|
|
71
|
+
]);
|
|
@@ -49,6 +49,14 @@ export class DeepModelLevel1 extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class DeepModelLevel2 extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class DeepModelLevel3 extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class DummyModel extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class DummyRelatedModel extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class FileTest extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class ModelWithCustomPKRelation extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class NameFilterCustomPKModel extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class Order extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class OrderItem extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class Product extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -49,6 +49,14 @@ export class ProductCategory extends Model {
|
|
|
49
49
|
configurable: true
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
// Bind this model to its backend
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-specific QuerySet implementation
|
|
3
|
+
*/
|
|
4
|
+
export class RatePlanQuerySet extends QuerySet<any> {
|
|
5
|
+
constructor(ModelClass: ModelConstructor, config?: {
|
|
6
|
+
nodes?: QueryNode[] | undefined;
|
|
7
|
+
orderBy?: {
|
|
8
|
+
field: string;
|
|
9
|
+
direction: "asc" | "desc";
|
|
10
|
+
}[] | undefined;
|
|
11
|
+
fields?: Set<string> | undefined;
|
|
12
|
+
aggregations?: Aggregation[] | undefined;
|
|
13
|
+
initialQueryset?: string | undefined;
|
|
14
|
+
serializerOptions?: SerializerOptions;
|
|
15
|
+
materialized?: boolean | undefined;
|
|
16
|
+
} | undefined, parent?: null);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Model-specific Manager implementation
|
|
20
|
+
*/
|
|
21
|
+
export class RatePlanManager extends Manager {
|
|
22
|
+
constructor(ModelClass: any);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Implementation of the RatePlan model
|
|
26
|
+
*/
|
|
27
|
+
export class RatePlan extends Model {
|
|
28
|
+
static configKey: string;
|
|
29
|
+
static modelName: string;
|
|
30
|
+
static primaryKeyField: string;
|
|
31
|
+
static objects: RatePlanManager;
|
|
32
|
+
static fields: string[];
|
|
33
|
+
static schema: any;
|
|
34
|
+
static relationshipFields: Map<any, any>;
|
|
35
|
+
constructor(data: any);
|
|
36
|
+
/**
|
|
37
|
+
* Define property getters and setters for all model fields
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
private _defineProperties;
|
|
41
|
+
}
|
|
42
|
+
import { QuerySet } from '../../../../src';
|
|
43
|
+
import { Manager } from '../../../../src';
|
|
44
|
+
import { Model } from '../../../../src';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated. Do not make direct changes to the file.
|
|
3
|
+
*/
|
|
4
|
+
import { Model, Manager, QuerySet, getModelClass } from '../../../../src';
|
|
5
|
+
import { wrapReactiveModel } from '../../../../src';
|
|
6
|
+
import schemaData from './rateplan.schema.json';
|
|
7
|
+
/**
|
|
8
|
+
* Model-specific QuerySet implementation
|
|
9
|
+
*/
|
|
10
|
+
export class RatePlanQuerySet extends QuerySet {
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Model-specific Manager implementation
|
|
14
|
+
*/
|
|
15
|
+
export class RatePlanManager extends Manager {
|
|
16
|
+
constructor(ModelClass) {
|
|
17
|
+
super(ModelClass, RatePlanQuerySet);
|
|
18
|
+
}
|
|
19
|
+
newQuerySet() {
|
|
20
|
+
return new RatePlanQuerySet(this.ModelClass);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Implementation of the RatePlan model
|
|
25
|
+
*/
|
|
26
|
+
export class RatePlan extends Model {
|
|
27
|
+
constructor(data) {
|
|
28
|
+
RatePlan.validateFields(data);
|
|
29
|
+
super(data);
|
|
30
|
+
// Define getters and setters for all fields
|
|
31
|
+
this._defineProperties();
|
|
32
|
+
return wrapReactiveModel(this);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Define property getters and setters for all model fields
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
_defineProperties() {
|
|
39
|
+
// For each field, define a property that gets/sets from internal storage
|
|
40
|
+
RatePlan.fields.forEach(field => {
|
|
41
|
+
Object.defineProperty(this, field, {
|
|
42
|
+
get: function () {
|
|
43
|
+
return this.getField(field);
|
|
44
|
+
},
|
|
45
|
+
set: function (value) {
|
|
46
|
+
this.setField(field, value);
|
|
47
|
+
},
|
|
48
|
+
enumerable: true, // Make sure fields are enumerable for serialization
|
|
49
|
+
configurable: true
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
// Add a special read-only getter for the repr field
|
|
53
|
+
Object.defineProperty(this, 'repr', {
|
|
54
|
+
get: function () {
|
|
55
|
+
return this.getField('repr');
|
|
56
|
+
},
|
|
57
|
+
enumerable: true, // Make sure repr is enumerable
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Bind this model to its backend
|
|
63
|
+
RatePlan.configKey = 'default';
|
|
64
|
+
RatePlan.modelName = 'django_app.rateplan';
|
|
65
|
+
RatePlan.primaryKeyField = 'id';
|
|
66
|
+
RatePlan.objects = new RatePlanManager(RatePlan);
|
|
67
|
+
RatePlan.fields = ['id', 'name'];
|
|
68
|
+
RatePlan.schema = schemaData;
|
|
69
|
+
RatePlan.relationshipFields = new Map([]);
|
|
@@ -133,7 +133,8 @@ export class ModelStore {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
if (item && typeof item.serialize === "function") {
|
|
136
|
-
|
|
136
|
+
// Pass includeRepr=true to preserve repr field in cache
|
|
137
|
+
const serializedItem = item.serialize(true);
|
|
137
138
|
serializedItem[pkField] = pk;
|
|
138
139
|
nonTempPkItems.push(serializedItem);
|
|
139
140
|
}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -154,7 +154,7 @@ await Product.objects.update({
|
|
|
154
154
|
// Just like Django's get_or_create
|
|
155
155
|
const [todo, created] = await Todo.objects.getOrCreate(
|
|
156
156
|
{ title: "Daily standup" },
|
|
157
|
-
{
|
|
157
|
+
{ priority: "medium", category: workCategory }
|
|
158
158
|
);
|
|
159
159
|
```
|
|
160
160
|
|