UNPKG

@statezero/core

Version:

The type-safe frontend client for StateZero - connect directly to your backend models with zero boilerplate

70 lines (69 loc) 2.23 kB
/** * This file was auto-generated. Do not make direct changes to the file. */ import { Model, Manager, QuerySet, getModelClass } from '../../../../src'; import { wrapReactiveModel } from '../../../../src'; import schemaData from './filetest.schema.json'; /** * Model-specific QuerySet implementation */ export class FileTestQuerySet extends QuerySet { } /** * Model-specific Manager implementation */ export class FileTestManager extends Manager { constructor(ModelClass) { super(ModelClass, FileTestQuerySet); } newQuerySet() { return new FileTestQuerySet(this.ModelClass); } } /** * Implementation of the FileTest model */ export class FileTest extends Model { constructor(data) { FileTest.validateFields(data); super(data); // Define getters and setters for all fields this._defineProperties(); return wrapReactiveModel(this); } /** * Define property getters and setters for all model fields * @private */ _defineProperties() { // For each field, define a property that gets/sets from internal storage FileTest.fields.forEach(field => { Object.defineProperty(this, field, { get: function () { return this.getField(field); }, set: function (value) { this.setField(field, value); }, enumerable: true, // Make sure fields are enumerable for serialization configurable: true }); }); // Add a special read-only getter for the repr field Object.defineProperty(this, 'repr', { get: function () { return this.getField('repr'); }, enumerable: true, // Make sure repr is enumerable configurable: true }); } } // Bind this model to its backend FileTest.configKey = 'default'; FileTest.modelName = 'django_app.filetest'; FileTest.primaryKeyField = 'id'; FileTest.objects = new FileTestManager(FileTest); FileTest.fields = ['id', 'title', 'document', 'image', 'created_at']; FileTest.schema = schemaData; FileTest.relationshipFields = new Map([]);