@onehat/data
Version:
JS data modeling package with adapters for many storage mediums.
10 lines (9 loc) • 327 kB
HTML
<html>
<head>
</head>
<body style="background: transparent;">
<script src="scripts/docstrap.lib.js"></script>
<script src="scripts/lunr.min.js"></script>
<script src="scripts/fulltext-search.js"></script>
<script type="text/x-docstrap-searchdb">
{"modules.list.html":{"id":"modules.list.html","title":"Modules","body":" @onehat/data Modules EntityOneHatDataPropertyReaderRepositorySchemaWriter@onehat/data Classes Entity~EntityOneHatData.OneHatDataReader~JsonReaderReader~ReaderReader~XmlReaderRepository~AjaxRepositoryRepository~CommandRepositoryRepository~LocalFromRemoteRepositoryRepository~MemoryRepositoryRepository~NullRepositoryRepository~OfflineRepositoryRepository~OneBuildRepositoryRepository~RestRepositoryWriter~JsonWriterWriter~WriterWriter~XmlWriter Modules Classes Entity OneHatData module:Property module:Property module:Property module:Property module:Property module:Property module:Property module:Property module:Property module:Property module:Property module:Property module:Property JsonReader Reader XmlReader AjaxRepository module:Repository CommandRepository LocalFromRemoteRepository MemoryRepository NullRepository OfflineRepository OneBuildRepository module:Repository RestRepository module:Schema JsonWriter Writer XmlWriter × Search results Close @onehat/data NPM Module@onehat/data Github Repo"},"classes.list.html":{"id":"classes.list.html","title":"Classes","body":" @onehat/data Modules EntityOneHatDataPropertyReaderRepositorySchemaWriter@onehat/data Classes Entity~EntityOneHatData.OneHatDataReader~JsonReaderReader~ReaderReader~XmlReaderRepository~AjaxRepositoryRepository~CommandRepositoryRepository~LocalFromRemoteRepositoryRepository~MemoryRepositoryRepository~NullRepositoryRepository~OfflineRepositoryRepository~OneBuildRepositoryRepository~RestRepositoryWriter~JsonWriterWriter~WriterWriter~XmlWriter Classes Classes Entity OneHatData module:Property module:Property module:Property module:Property module:Property module:Property module:Property module:Property module:Property module:Property module:Property module:Property module:Property JsonReader Reader XmlReader AjaxRepository module:Repository CommandRepository LocalFromRemoteRepository MemoryRepository NullRepository OfflineRepository OneBuildRepository module:Repository RestRepository module:Schema JsonWriter Writer XmlWriter × Search results Close @onehat/data NPM Module@onehat/data Github Repo"},"index.html":{"id":"index.html","title":"Index","body":" @onehat/data Modules EntityOneHatDataPropertyReaderRepositorySchemaWriter@onehat/data Classes Entity~EntityOneHatData.OneHatDataReader~JsonReaderReader~ReaderReader~XmlReaderRepository~AjaxRepositoryRepository~CommandRepositoryRepository~LocalFromRemoteRepositoryRepository~MemoryRepositoryRepository~NullRepositoryRepository~OfflineRepositoryRepository~OneBuildRepositoryRepository~RestRepositoryWriter~JsonWriterWriter~WriterWriter~XmlWriter Overview @onehat/data A robust ORM for Javascript. Can CRUD, search, sort, filter, paginate your data. Integrates with many front- and back-end storage mediums. Repositories. A Repository stores many Entities in a storage medium. Corresponds to a database table. Repositories can sort, search/filter, and add/edit/delete their constituent Entities. Storage Mediums. Repositories are specialized to store their data in a single type of storage medium. Available types of Repositories include: Memory, Ajax, Rest, LocalStorage (Browser), SessionStorage (Browser), IndexedDB (Browser), AsyncStorage (React Native/Expo), SecureStore (React Native/Expo). One special type of Repository—LocalFromRemote—combines two different Repository types (one local and one remote) into a single Repository, thereby allowing autosyncing between the local and remote repositories, enabling true offline-first capability. Entities. An Entity is a single record of data, organized into properties. Corresponds to a database row. Entity data can be accessed directly (entity.username), via specific properties and their formatted values (entity.properties.username.displayValue), or by obtaining a JS object of the whole Entity (entity.getDisplayValues(), or entity.getSubmitValues()). Properties. A Property is a single unit of data. Corresponds to a database field. Properties are differentiated into different Property types (e.g. Integer, String, Boolean, etc), and thereby allow for easy formatting of \"display\" or \"submit\" values. For example, a date might be set to display as \"Wed, Feb 5, 2020\" but submit as \"2020-02-05\". Schemas. A Schema defines the configuration of a Repository. Corresponds roughly to the database table schema. The Schema defines the name and type of Repository, the Properties that exist, and which are \"id\" and \"display\" Properties. Install npm i @onehat/data Usage Comprehensive unit tests can be found in ./cypress/integration. These are an excellent source of code examples. Comprehensive API documentation can be found in ./docs. 1. Define a Schema For every type of Entity you will use (e.g. Users or Animals or Invoices), define a Schema. A Schema determines the various Properties that each Entity will have, as well as the medium where the Entities will be stored. const Users = { name: 'Users', model: { idProperty: 'id', displayProperty: 'username', properties: [ { name: 'id', type: 'int', }, { name: 'username', type: 'string', }, // explicitly set property type { name: 'password', }, // type: 'string' is assumed, if not explicitly set { name: 'first_name', }, { name: 'last_name', }, { name: 'email', allowNull: false, }, // make it a required field { name: 'last_login', type: 'datetime', defaultValue: 'now', }, // give it a default value. ], sorters: [ { name: 'last_name', direction: 'ASC', }, { name: 'first_name', direction: 'ASC', }, ], }, repository: 'memory', // Repository type. Can be string name or config object }; export default Users; Every Property must have a unique name. All other attributes are optional. Common Property attributes include: name - The name of the Property type - The type of the Property (e.g. 'string', 'bool', 'int', etc) allowNull - Is this Property required to have a value? defaultValue - Default value for this Property if none is supplied isSortable - Whether this Property type is sortable Other Property attributes exist and can be found in the API. 2. Create a Repository The easiest way to create one or more Repositories is to use the global oneHatData singleton object. Each schema will have a bound repository of the same name (e.g. \"Users\", or \"Groups\"). import oneHatData from '@onehat/data'; import Groups from './Groups'; import Users from './Users'; oneHatData .createSchemas([ Groups, Users, ]) .createBoundRepositories() .then(() => { setIsReady(true); const UsersRepository = oneHatData.getRepository('Users'); // Do something with your data }); 3. Add / Edit / Delete an Entity Once you have a Repository initialized, you can start adding data to it. Data is manipulated asynchronously, so you may optionally wait for it to complete. const UsersRepository = oneHatData.getRepository('Users'); // 1. Add an Entity const userEntity = await UsersRepository.add({ username: 'ajones', password: '12345', first_name: 'Alice', last_name: 'Jones', email: 'alice@example.com', }); // 2. Edit an Entity // Use assignment to change the value of a particular Property. userEntity.password = 'mypass'; // Or you can be more verbose about it userEntity.getProperty('password').setValue('mypass'); // 3. Delete an Entity userEntity.delete(); // Or delete it from the Repository await UsersRepository.delete(userEntity); 4. Filter and Sort the Entities in a Repository There are lots of filtering and sorting methods available on Repositories. // Add a single filter UsersRepository.filter('first_name', 'Alice'); const foundEntities = UsersRepository.entities; // Or search by an id or function const myEntity = UsersRepository.getById(1); const results = UsersRepository.getBy((entity) => { return entity.id > 2; }); // Sort the entities by a particular Property UsersRepository.sort('last_name', 'DESC'); const sortedEntities = UsersRepository.entities; 5. Listen for events and respond to them Repositories, Entities, and Properties emit many different kinds of events. // The 'change' event, emitted from an Entity, is relayed through the Repository and becomes 'entity_change' UsersRepository.on('entity_change', (entity) => { console.log('changed entity'); }); userEntity.first_name = 'Joe'; // prints 'changed entity' to console // The 'changeData' event is fired from the Repository after multiple Entities are loaded at once UsersRepository.on('changeData', (entities) => { console.log('entities changed'); }); UsersRepository.load([ { email: 'alice@example.com' }, { email: 'bob@example.com' }, { email: 'charlie@example.com' }, ]); // prints 'entities changed' to console × Search results Close @onehat/data NPM Module@onehat/data Github Repo"},"module-Entity.html":{"id":"module-Entity.html","title":"Module: Entity","body":" @onehat/data Modules EntityOneHatDataPropertyReaderRepositorySchemaWriter@onehat/data Classes Entity~EntityOneHatData.OneHatDataReader~JsonReaderReader~ReaderReader~XmlReaderRepository~AjaxRepositoryRepository~CommandRepositoryRepository~LocalFromRemoteRepositoryRepository~MemoryRepositoryRepository~NullRepositoryRepository~OfflineRepositoryRepository~OneBuildRepositoryRepository~RestRepositoryWriter~JsonWriterWriter~WriterWriter~XmlWriter Module: Entity Source: Entity.js Classes Entity Members <inner, readonly> name :string Type: string Source: Entity.js <inner> properties :Object Object of all Properties, keyed by id (for quick access) These properties are actually created in the initialize() function. Type: Object Source: Entity.js <inner> isInitialized :Boolean State: whether or not this entity has been completely initialized Type: Boolean Source: Entity.js × Search results Close @onehat/data NPM Module@onehat/data Github Repo"},"module-Entity-Entity.html":{"id":"module-Entity-Entity.html","title":"Class: Entity","body":" @onehat/data Modules EntityOneHatDataPropertyReaderRepositorySchemaWriter@onehat/data Classes Entity~EntityOneHatData.OneHatDataReader~JsonReaderReader~ReaderReader~XmlReaderRepository~AjaxRepositoryRepository~CommandRepositoryRepository~LocalFromRemoteRepositoryRepository~MemoryRepositoryRepository~NullRepositoryRepository~OfflineRepositoryRepository~OneBuildRepositoryRepository~RestRepositoryWriter~JsonWriterWriter~WriterWriter~XmlWriter Class: Entity Entity~ Entity Class represents a single Entity (i.e. a record) which is a collection of Properties with current values. Usage: Setting data options: - entity.users__last_name = 'Smith'; - entity.setValue('users__last_name', 'Smith'); - entity.setValues({ users__last_name: 'Smith', }); Getting data options: - entity.data; // Gets all property values as single JSON object - entity.users__last_name; - entity.getPropertySubmitValue('users__last_name'); new Entity(schema, rawData) Parameters: Name Type Description schema Schema Schema object rawData object Raw data object. Keys are Property names, Values are Property values. Source: Entity.js Fires: .'change', 'reset', 'save', 'delete',event: 'destroy'] Extends EventEmitter Members createId Generates a new unique id and assigns it to this entity. If the idProperty is of type 'uuid', then it generates a new UUID. If not, then it generates a temp id. Source: Entity.js loadOriginalData Manually load originalData into this Entity, *after* the entity has already been created. This resets the Entity, so it's 'as new'. This is mainly for updating Entity with new data from remote storage medium. Assumes (and sets) isPersisted === true. Source: Entity.js reset Resets the Entity to a state as if it had just been created, all based on _originalData. Source: Entity.js hasProperty Checks to see if a property exists Source: Entity.js getSchema Gets the Schema object Source: Entity.js prop Alias for this.properties Source: Entity.js getProperty Gets a single Property by name, Source: Entity.js getPropertySubmitValue Gets the \"submit\" value of one Property, Source: Entity.js getPropertyDisplayValue Gets the \"display\" value of one Property, Source: Entity.js getSubmitValues Gets an object of properties/values for this Entity, Values are the \"submit\" values, not the \"raw\" or \"parsed\" or \"display\" values. Source: Entity.js submitValues Gets \"submit\" values for this Entity. Source: Entity.js getDisplayValues Gets an object of values for this Entity, Values are the \"display\" values, not the \"raw\" or \"parsed\" or \"submit\" values. Source: Entity.js displayValues Gets \"display\" values for this Entity. Source: Entity.js getRawValues Gets an object of values for this Entity, Values are the \"raw\" values, not the \"parsed\" or \"submit\" or \"display\" values. Source: Entity.js rawValues Gets \"raw\" values for this Entity. Source: Entity.js getParsedValues Gets an object of values for this Entity, Values are the \"parsed\" values, not the \"raw\" or \"submit\" or \"display\" values. Source: Entity.js parsedValues Gets \"parsed\" values for this Entity. Source: Entity.js getChanged Gets the values that have changed since last time saved Source: Entity.js data Alias for this.submitValues Source: Entity.js getPropertiesBy Get all Property objects that pass a supplied filter. Source: Entity.js getIdProperty Gets the \"id\" Property object for this Entity. This is the Property whose value represents the id for the whole Entity itself. Source: Entity.js getId Gets the id for this Entity. Source: Entity.js id Getter of the id for this Entity. Source: Entity.js getDisplayProperty Gets the \"Display\" Property object for this Entity. This is the Property whose value can easily identify the whole Entity itself. Source: Entity.js getDisplayValue Gets the \"Display\" value for this Entity. This value should easily identify the whole Entity itself. Source: Entity.js displayValue Getter of the \"Display\" value for this Entity. This value should easily identify the whole Entity itself. Source: Entity.js isPhantom Getter of isPhantom for this Entity. Entity is phantom if it has either no id or a temp id. Source: Entity.js isDirty Getter of isDirty for this Entity. Entity is dirty if it has any Property changes that have not been persisted to storage medium. Practically, this means it has any values that are different from this._originalData. Source: Entity.js setId Sets the id for this entity. Note: Does *not* fire any change events. Source: Entity.js setValue Sets a single Property value Source: Entity.js setValues Sets Property values Source: Entity.js save Tells the Repository to save this entity to the storage medium. Source: Entity.js markSaved Marks an entity as having been saved to storage medium. Source: Entity.js markDeleted Marks an entity as having been saved to storage medium. Source: Entity.js delete Tells the Repository to delete this entity from the storage medium. Source: Entity.js destroy Destroy this object. - Removes all circular references to parent objects - Removes child objects - Removes event listeners Source: Entity.js Methods <static> isTempId(id) Determines whether submitted id is a \"temp\" id. Parameters: Name Type Description id any Source: Entity.js Returns: isTempId Type boolean × Search results Close @onehat/data NPM Module@onehat/data Github Repo"},"module-OneHatData.html":{"id":"module-OneHatData.html","title":"Module: OneHatData","body":" @onehat/data Modules EntityOneHatDataPropertyReaderRepositorySchemaWriter@onehat/data Classes Entity~EntityOneHatData.OneHatDataReader~JsonReaderReader~ReaderReader~XmlReaderRepository~AjaxRepositoryRepository~CommandRepositoryRepository~LocalFromRemoteRepositoryRepository~MemoryRepositoryRepository~NullRepositoryRepository~OfflineRepositoryRepository~OneBuildRepositoryRepository~RestRepositoryWriter~JsonWriterWriter~WriterWriter~XmlWriter Module: OneHatData Source: OneHatData.js Classes OneHatData Members <inner> Get Source: OneHatData.js <inner> Get Source: OneHatData.js × Search results Close @onehat/data NPM Module@onehat/data Github Repo"},"module-OneHatData.OneHatData.html":{"id":"module-OneHatData.OneHatData.html","title":"Class: OneHatData","body":" @onehat/data Modules EntityOneHatDataPropertyReaderRepositorySchemaWriter@onehat/data Classes Entity~EntityOneHatData.OneHatDataReader~JsonReaderReader~ReaderReader~XmlReaderRepository~AjaxRepositoryRepository~CommandRepositoryRepository~LocalFromRemoteRepositoryRepository~MemoryRepositoryRepository~NullRepositoryRepository~OfflineRepositoryRepository~OneBuildRepositoryRepository~RestRepositoryWriter~JsonWriterWriter~WriterWriter~XmlWriter Class: OneHatData OneHatData. OneHatData OneHatData represents a collection of Repositories. It is the top-level object for this module. Normally used as a global singleton within an app, using the exported 'oneHatData' constant new OneHatData() Source: OneHatData.js Extends EventEmitter Members setRepositoryGlobals Sets global config settings that will be passed into all Repositories. Chainable. Source: OneHatData.js createSchemas Creates one or more Schemas at once. Chainable. Source: OneHatData.js createRepository Creates a new Repository. Source: OneHatData.js _createRepository Helper for createRepository. Source: OneHatData.js getSchema Get a Schema by its name Source: OneHatData.js getSchemasBy Get Schemas by a filter function Source: OneHatData.js getAllRepositories Get all Repositories Source: OneHatData.js getRepository Get the Repository bound to the Schema with the supplied name. Source: OneHatData.js getRepositoriesBy Get Repositories by a filter function Source: OneHatData.js getRepositoryById Get a Repository by its id Source: OneHatData.js hasSchemaWithName Checks whether a Schema with the supplied name exists Source: OneHatData.js hasRepositoryWithId Checks whether a Repository with the supplied ID exists Source: OneHatData.js destroy Destroy this object. - Removes child objects - Removes event listeners Source: OneHatData.js × Search results Close @onehat/data NPM Module@onehat/data Github Repo"},"module-Property.html":{"id":"module-Property.html","title":"Module: Property","body":" @onehat/data Modules EntityOneHatDataPropertyReaderRepositorySchemaWriter@onehat/data Classes Entity~EntityOneHatData.OneHatDataReader~JsonReaderReader~ReaderReader~XmlReaderRepository~AjaxRepositoryRepository~CommandRepositoryRepository~LocalFromRemoteRepositoryRepository~MemoryRepositoryRepository~NullRepositoryRepository~OfflineRepositoryRepository~OneBuildRepositoryRepository~RestRepositoryWriter~JsonWriterWriter~WriterWriter~XmlWriter Module: Property Class represents a Property that stores Base64 data. This class contains helpful methods in dealing with Base64 data. Class represents a Property that stores boolean data. Class represents a Property that stores currency data. Class represents a Property that stores a calendar date. Class represents a Property that stores a calendar date and time. Class represents a Property that stores file data. Class represents a Property that stores a float value. Class represents a Property that stores an integer value. Class represents a Property that stores JSON data. JsonProperty may be a little unpredictable in what its various methods will give you. Say you set the value to: '{\"test\":true}'. The property parses this and converts it to an actual JS object internally. There will then be two possible representations of this value: - A string ('{\"test\":true}') and - An object ({ test: true }). This is what the various methods will give you: - getParsedValue: object - getDisplayValue: string - getRawValue: string - getSubmitValue (default): string - getSubmitValue when !submitAsString: object The submitValue is where things get weird. By default, this property will submit as a string. Base class representing a Property This class should not be instantiated directly. Rather, instantiate a subclass, like StringProperty Class represents a Property that stores string data. Class represents a Property that stores a time of day. Class represents a Property that stores a UUID. This class contains helpful methods in dealing with UUIDs. new (require(\"Property\"))() Source: Property/Base64.js new (require(\"Property\"))() Source: Property/Boolean.js new (require(\"Property\"))() Source: Property/Currency.js new (require(\"Property\"))() Source: Property/Date.js new (require(\"Property\"))() Source: Property/DateTime.js new (require(\"Property\"))() Source: Property/File.js new (require(\"Property\"))() Source: Property/Float.js new (require(\"Property\"))() Source: Property/Integer.js new (require(\"Property\"))() Source: Property/Json.js new (require(\"Property\"))(config) Parameters: Name Type Description config object Object with key/value pairs that define this Property Source: Property/Property.js Fires: .'change',event: 'destroy'] new (require(\"Property\"))() Source: Property/String.js new (require(\"Property\"))() Source: Property/Time.js new (require(\"Property\"))() Source: Property/Uuid.js Members decode Decodes to UTF-8 string Source: Property/Base64.js atob Decodes to bytes, which is compatible with browser's built-in atob() (Which is absent in node) Source: Property/Base64.js parse Parses value to moment object Source: Property/Date.js parse Parses value to float Source: Property/Float.js isValid Validates a JSON string Source: Property/Json.js getAsHtmlSafe Utility function - gets the JSON string in a way that is safe to display in HTML. i.e. It enables us to show a JSON string in HTML *without its contents being interpreted as HTML* Source: Property/Json.js <inner> name :string Could be anything, but OneHat's convention is to use the model name pluralized and underscored, followed by two underscores, followed by the field name singular and underscored (e.g. 'groups_users__id') This convention allows us to have multiple models' data in a single Entity, all flattened Type: string Source: Property/Property.js <inner> allowNull :boolean Is the property required to have a value? Defaults to true. Type: boolean Source: Property/Property.js <inner> submitAsString :boolean Whether to submit value as a string, rather than a primitive or complex type Type: boolean Source: Property/Property.js <inner> isSortable :boolean Whether this property type is sortable Type: boolean Source: Property/Property.js <inner> rawValue :any The raw value supplied to this property, *before* any parsing was applied Type: any Source: Property/Property.js <inner> parsedValue :any The value for this property, *after* any parsing was applied Type: any Source: Property/Property.js getRawValue Gets \"raw\" value, prior to any parsing Source: Property/Property.js getParsedValue Gets \"parsed\" value, without any formatting applied Source: Property/Property.js getSubmitValue Gets parsed value, formatted for submission to server Source: Property/Property.js submitValue Gets parsed value, formatted for submission to server Source: Property/Property.js getDisplayValue Gets parsed value, formatted for displaying to user Source: Property/Property.js displayValue Gets parsed value, formatted for displaying to user Source: Property/Property.js hasMapping Gets whether or not the Property has a mapping. Used by Entity. Source: Property/Property.js hasDepends Gets whether or not the Property depends on any other properties for its local \"parse\" function. Used by Entity. Source: Property/Property.js isIdProperty Gets whether or not the Property is an \"ID\" property for the Entity it's assigned to Source: Property/Property.js isDisplayProperty Gets whether or not the Property is a \"Display\" property for the Entity it's assigned to Source: Property/Property.js setValue Sets the parsedValue for this Property. Any mapping for this property has already taken place. i.e. The rawValue to parse *is the mapped value.* Source: Property/Property.js parse Performs the actual parsing conversion, but *does not* set anything on the property. Default function. Meant to be overridden with subclass. Source: Property/Property.js setSubmitAsString Sets value of submitAsString Source: Property/Property.js getEntity Gets the Entity object Source: Property/Property.js getClassName Gets the className of this Property type. Source: Property/Property.js destroy Destroy this object. - Removes all circular references to parent objects - Removes child objects - Removes event listeners Source: Property/Property.js parse Parses value to string. - Strings will pass through unaltered. - Numbers and Booleans will be converted to strings. - Other types will return null. Source: Property/String.js newId Generates a new UUID Source: Property/Uuid.js isValid Validates a UUID Source: Property/Uuid.js isEmpty Determines whether a given UUID is empty (i.e. all zeros) Source: Property/Uuid.js Methods getDefaultValue() Gets default value. In this case, if a property is set to have a defaultValue of 'now', it will default to the current Date. Source: Property/Date.js Returns: defaultValue Type any getDefaultValue() Gets default value. Can be overridden to get dynamic default value. Source: Property/Property.js Returns: defaultValue Type any getDefaultValue() Gets default value. In this case, if a property is set to have a defaultValue of 'generate', it will default to a newly generated UUID. Source: Property/Uuid.js Returns: defaultValue Type any Module: Property Class represents a Property that stores Base64 data. This class contains helpful methods in dealing with Base64 data. Class represents a Property that stores boolean data. Class represents a Property that stores currency data. Class represents a Property that stores a calendar date. Class represents a Property that stores a calendar date and time. Class represents a Property that stores file data. Class represents a Property that stores a float value. Class represents a Property that stores an integer value. Class represents a Property that stores JSON data. JsonProperty may be a little unpredictable in what its various methods will give you. Say you set the value to: '{\"test\":true}'. The property parses this and converts it to an actual JS object internally. There will then be two possible representations of this value: - A string ('{\"test\":true}') and - An object ({ test: true }). This is what the various methods will give you: - getParsedValue: object - getDisplayValue: string - getRawValue: string - getSubmitValue (default): string - getSubmitValue when !submitAsString: object The submitValue is where things get weird. By default, this property will submit as a string. Base class representing a Property This class should not be instantiated directly. Rather, instantiate a subclass, like StringProperty Class represents a Property that stores string data. Class represents a Property that stores a time of day. Class represents a Property that stores a UUID. This class contains helpful methods in dealing with UUIDs. new (require(\"Property\"))() Source: Property/Base64.js new (require(\"Property\"))() Source: Property/Boolean.js new (require(\"Property\"))() Source: Property/Currency.js new (require(\"Property\"))() Source: Property/Date.js new (require(\"Property\"))() Source: Property/DateTime.js new (require(\"Property\"))() Source: Property/File.js new (require(\"Property\"))() Source: Property/Float.js new (require(\"Property\"))() Source: Property/Integer.js new (require(\"Property\"))() Source: Property/Json.js new (require(\"Property\"))(config) Parameters: Name Type Description config object Object with key/value pairs that define this Property Source: Property/Property.js Fires: .'change',event: 'destroy'] new (require(\"Property\"))() Source: Property/String.js new (require(\"Property\"))() Source: Property/Time.js new (require(\"Property\"))() Source: Property/Uuid.js Members decode Decodes to UTF-8 string Source: Property/Base64.js atob Decodes to bytes, which is compatible with browser's built-in atob() (Which is absent in node) Source: Property/Base64.js parse Parses value to moment object Source: Property/Date.js parse Parses value to float Source: Property/Float.js isValid Validates a JSON string Source: Property/Json.js getAsHtmlSafe Utility function - gets the JSON string in a way that is safe to display in HTML. i.e. It enables us to show a JSON string in HTML *without its contents being interpreted as HTML* Source: Property/Json.js <inner> name :string Could be anything, but OneHat's convention is to use the model name pluralized and underscored, followed by two underscores, followed by the field name singular and underscored (e.g. 'groups_users__id') This convention allows us to have multiple models' data in a single Entity, all flattened Type: string Source: Property/Property.js <inner> allowNull :boolean Is the property required to have a value? Defaults to true. Type: boolean Source: Property/Property.js <inner> submitAsString :boolean Whether to submit value as a string, rather than a primitive or complex type Type: boolean Source: Property/Property.js <inner> isSortable :boolean Whether this property type is sortable Type: boolean Source: Property/Property.js <inner> rawValue :any The raw value supplied to this property, *before* any parsing was applied Type: any Source: Property/Property.js <inner> parsedValue :any The value for this property, *after* any parsing was applied Type: any Source: Property/Property.js getRawValue Gets \"raw\" value, prior to any parsing Source: Property/Property.js getParsedValue Gets \"parsed\" value, without any formatting applied Source: Property/Property.js getSubmitValue Gets parsed value, formatted for submission to server Source: Property/Property.js submitValue Gets parsed value, formatted for submission to server Source: Property/Property.js getDisplayValue Gets parsed value, formatted for displaying to user Source: Property/Property.js displayValue Gets parsed value, formatted for displaying to user Source: Property/Property.js hasMapping Gets whether or not the Property has a mapping. Used by Entity. Source: Property/Property.js hasDepends Gets whether or not the Property depends on any other properties for its local \"parse\" function. Used by Entity. Source: Property/Property.js isIdProperty Gets whether or not the Property is an \"ID\" property for the Entity it's assigned to Source: Property/Property.js isDisplayProperty Gets whether or not the Property is a \"Display\" property for the Entity it's assigned to Source: Property/Property.js setValue Sets the parsedValue for this Property. Any mapping for this property has already taken place. i.e. The rawValue to parse *is the mapped value.* Source: Property/Property.js parse Performs the actual parsing conversion, but *does not* set anything on the property. Default function. Meant to be overridden with subclass. Source: Property/Property.js setSubmitAsString Sets value of submitAsString Source: Property/Property.js getEntity Gets the Entity object Source: Property/Property.js getClassName Gets the className of this Property type. Source: Property/Property.js destroy Destroy this object. - Removes all circular references to parent objects - Removes child objects - Removes event listeners Source: Property/Property.js parse Parses value to string. - Strings will pass through unaltered. - Numbers and Booleans will be converted to strings. - Other types will return null. Source: Property/String.js newId Generates a new UUID Source: Property/Uuid.js isValid Validates a UUID Source: Property/Uuid.js isEmpty Determines whether a given UUID is empty (i.e. all zeros) Source: Property/Uuid.js Methods getDefaultValue() Gets default value. In this case, if a property is set to have a defaultValue of 'now', it will default to the current Date. Source: Property/Date.js Returns: defaultValue Type any getDefaultValue() Gets default value. Can be overridden to get dynamic default value. Source: Property/Property.js Returns: defaultValue Type any getDefaultValue() Gets default value. In this case, if a property is set to have a defaultValue of 'generate', it will default to a newly generated UUID. Source: Property/Uuid.js Returns: defaultValue Type any Module: Property Class represents a Property that stores Base64 data. This class contains helpful methods in dealing with Base64 data. Class represents a Property that stores boolean data. Class represents a Property that stores currency data. Class represents a Property that stores a calendar date. Class represents a Property that stores a calendar date and time. Class represents a Property that stores file data. Class represents a Property that stores a float value. Class represents a Property that stores an integer value. Class represents a Property that stores JSON data. JsonProperty may be a little unpredictable in what its various methods will give you. Say you set the value to: '{\"test\":true}'. The property parses this and converts it to an actual JS object internally. There will then be two possible representations of this value: - A string ('{\"test\":true}') and - An object ({ test: true }). This is what the various methods will give you: - getParsedValue: object - getDisplayValue: string - getRawValue: string - getSubmitValue (default): string - getSubmitValue when !submitAsString: object The submitValue is where things get weird. By default, this property will submit as a string. Base class representing a Property This class should not be instantiated directly. Rather, instantiate a subclass, like StringProperty Class represents a Property that stores string data. Class represents a Property that stores a time of day. Class represents a Property that stores a UUID. This class contains helpful methods in dealing with UUIDs. new (require(\"Property\"))() Source: Property/Base64.js new (require(\"Property\"))() Source: Property/Boolean.js new (require(\"Property\"))() Source: Property/Currency.js new (require(\"Property\"))() Source: Property/Date.js new (require(\"Property\"))() Source: Property/DateTime.js new (require(\"Property\"))() Source: Property/File.js new (require(\"Property\"))() Source: Property/Float.js new (require(\"Property\"))() Source: Property/Integer.js new (require(\"Property\"))() Source: Property/Json.js new (require(\"Property\"))(config) Parameters: Name Type Description config object Object with key/value pairs that define this Property Source: Property/Property.js Fires: .'change',event: 'destroy'] new (require(\"Property\"))() Source: Property/String.js new (require(\"Property\"))() Source: Property/Time.js new (require(\"Property\"))() Source: Property/Uuid.js Members decode Decodes to UTF-8 string Source: Property/Base64.js atob Decodes to bytes, which is compatible with browser's built-in atob() (Which is absent in node) Source: Property/Base64.js parse Parses value to moment object Source: Property/Date.js parse Parses value to float Source: Property/Float.js isValid Validates a JSON string Source: Property/Json.js getAsHtmlSafe Utility function - gets the JSON string in a way that is safe to display in HTML. i.e. It enables us to show a JSON string in HTML *without its contents being interpreted as HTML* Source: Property/Json.js <inner> name :string Could be anything, but OneHat's convention is to use the model name pluralized and underscored, followed by two underscores, followed by the field name singular and underscored (e.g. 'groups_users__id') This convention allows us to have multiple models' data in a single Entity, all flattened Type: string Source: Property/Property.js <inner> allowNull :boolean Is the property required to have a value? Defaults to true. Type: boolean Source: Property/Property.js <inner> submitAsString :boolean Whether to submit value as a string, rather than a primitive or complex type Type: boolean Source: Property/Property.js <inner> isSortable :boolean Whether this property type is sortable Type: boolean Source: Property/Property.js <inner> rawValue :any The raw value supplied to this property, *before* any parsing was applied Type: any Source: Property/Property.js <inner> parsedValue :any The value for this property, *after* any parsing was applied Type: any Source: Property/Property.js getRawValue Gets \"raw\" value, prior to any parsing Source: Property/Property.js getParsedValue Gets \"parsed\" value, without any formatting applied Source: Property/Property.js getSubmitValue Gets parsed value, formatted for submission to server Source: Property/Property.js submitValue Gets parsed value, formatted for submission to server Source: Property/Property.js getDisplayValue Gets parsed value, formatted for displaying to user Source: Property/Property.js displayValue Gets parsed value, formatted for displaying to user Source: Property/Property.js hasMapping Gets whether or not the Property has a mapping. Used by Entity. Source: Property/Property.js hasDepends Gets whether or not the Property depends on any other properties for its local \"parse\" function. Used by Entity. Source: Property/Property.js isIdProperty Gets whether or not the Property is an \"ID\" property for the Entity it's assigned to Source: Property/Property.js isDisplayProperty Gets whether or not the Property is a \"Display\" property for the Entity it's assigned to Source: Property/Property.js setValue Sets the parsedValue for this Property. Any mapping for this property has already taken place. i.e. The rawValue to parse *is the mapped value.* Source: Property/Property.js parse Performs the actual parsing conversion, but *does not* set anything on the property. Default function. Meant to be overridden with subclass. Source: Property/Property.js setSubmitAsString Sets value of submitAsString Source: Property/Property.js getEntity Gets the Entity object Source: Property/Property.js getClassName Gets the className of this Property type. Source: Property/Property.js destroy Destroy this object. - Removes all circular references to parent objects - Removes child objects - Removes event listeners Source: Property/Property.js parse Parses value to string. - Strings will pass through unaltered. - Numbers and Booleans will be converted to strings. - Other types will return null. Source: Property/String.js newId Generates a new UUID Source: Property/Uuid.js isValid Validates a UUID Source: Property/Uuid.js isEmpty Determines whether a given UUID is empty (i.e. all zeros) Source: Property/Uuid.js Methods getDefaultValue() Gets default value. In this case, if a property is set to have a defaultValue of 'now', it will default to the current Date. Source: Property/Date.js Returns: defaultValue Type any getDefaultValue() Gets default value. Can be overridden to get dynamic default value. Source: Property/Property.js Returns: defaultValue Type any getDefaultValue() Gets default value. In this case, if a property is set to have a defaultValue of 'generate', it will default to a newly generated UUID. Source: Property/Uuid.js Returns: defaultValue Type any Module: Property Class represents a Property that stores Base64 data. This class contains helpful methods in dealing with Base64 data. Class represents a Property that stores boolean data. Class represents a Property that stores currency data. Class represents a Property that stores a calendar date. Class represents a Property that stores a calendar date and time. Class represents a Property that stores file data. Class represents a Property that stores a float value. Class represents a Property that stores an integer value. Class represents a Property that stores JSON data. JsonProperty may be a little unpredictable in what its various methods will give you. Say you set the value to: '{\"test\":true}'. The property parses this and converts it to an actual JS object internally. There will then be two possible representations of this value: - A string ('{\"test\":true}') and - An object ({ test: true }). This is what the various methods will give you: - getParsedValue: object - getDisplayValue: string - getRawValue: string - getSubmitValue (default): string - getSubmitValue when !submitAsString: object The submitValue is where things get weird. By default, this property will submit as a string. Base class representing a Property This class should not be instantiated directly. Rather, instantiate a subclass, like StringProperty Class represents a Property that stores string data. Class represents a Property that stores a time of day. Class represents a Property that stores a UUID. This class contains helpful methods in dealing with UUIDs. new (require(\"Property\"))() Source: Property/Base64.js new (require(\"Property\"))() Source: Property/Boolean.js new (require(\"Property\"))() Source: Property/Currency.js new (require(\"Property\"))() Source: Property/Date.js new (require(\"Property\"))() Source: Property/DateTime.js new (require(\"Property\"))() Source: Property/File.js new (require(\"Property\"))() Source: Property/Float.js new (require(\"Property\"))() Source: Property/Integer.js new (require(\"Property\"))() Source: Property/Json.js new (require(\"Property\"))(config) Parameters: Name Type Description config object Object with key/value pairs that define this Property Source: Property/Property.js Fires: .'change',event: 'destroy'] new (require(\"Property\"))() Source: Property/String.js new (require(\"Property\"))() Source: Property/Time.js new (require(\"Property\"))() Source: Property/Uuid.js Members decode Decodes to UTF-8 string Source: Property/Base64.js atob Decodes to bytes, which is compatible with browser's built-in atob() (Which is absent in node) Source: Property/Base64.js parse Parses value to moment object Source: Property/Date.js parse Parses value to float Source: Property/Float.js isValid Validates a JSON string Source: Property/Json.js getAsHtmlSafe Utility function - gets the JSON string in a way that is safe to display in HTML. i.e. It enables us to show a JSON string in HTML *without its contents being interpreted as HTML* Source: Property/Json.js <inner> name :string Could be anything, but OneHat's convention is to use the model name pluralized and underscored, followed by two underscores, followed by the field name singular and underscored (e.g. 'groups_users__id') This convention allows us to have multiple models' data in a single Entity, all flattened Type: string Source: Property/Property.js <inner> allowNull :boolean Is the property required to have a value? Defaults to true. Type: boolean Source: Property/Property.js <inner> submitAsString :boolean Whether to submit value as a string, rather than a primitive or complex type Type: boolean Source: Property/Property.js <inner> isSortable :boolean Whether this property type is sortable Type: boolean Source: Property/Property.js <inner> rawValue :any The raw value supplied to this property, *before* any parsing was applied Type: any Source: Property/Property.js <inner> parsedValue :any The value for this property, *after* any parsing was applied Type: any Source: Property/Property.js getRawValue Gets \"raw\" value, prior to any parsing Source: Property/Property.js getParsedValue Gets \"parsed\" value, without any formatting applied Source: Property/Property.js getSubmitValue Gets parsed value, formatted for submission to server Source: Property/Property.js submitValue Gets parsed value, formatted for submission to server Source: Property/Property.js getDisplayValue Gets parsed value, formatted for displaying to user Source: Property/Property.js displayValue Gets parsed value, formatted for displaying to user Source: Property/Property.js hasMapping Gets whether or not the Property has a mapping. Used by Entity. Source: Property/Property.js hasDepends Gets whether or not the Property depends on any other properties for its local \"parse\" function. Used by Entity. Source: Property/Property.js isIdProperty Gets whether or not the Property is an \"ID\" property for the Entity it's assigned to Source: Property/Property.js isDisplayProperty Gets whether or not the Property is a \"Display\" property for the Entity it's assigned to Source: Property/Property.js setValue Sets the parsedValue for this Property. Any mapping for this property has already taken place. i.e. The rawValue to parse *is the mapped value.* Source: Property/Property.js parse Performs the actual parsing conversion, but *does not* set anything on the property. Default function. Meant to be overridden with subclass. Source: Property/Property.js setSubmitAsString Sets value of submitAsString Source: Property/Property.js getEntity Gets the Entity object Source: Property/Property.js getClassName Gets the className of this Property type. Source: Property/Property.js destroy Destroy this object. - Removes all circular references to parent objects - Removes child objects - Removes event listeners Source: Property/Property.js parse Parses value to string. - Strings will pass through unaltered. - Numbers and Booleans will be converted to strings. - Other types will return null. Source: Property/String.js newId Generates a new UUID Source: Property/Uuid.js isValid Validates a UUID Source: Property/Uuid.js isEmpty Determines whether a given UUID is empty (i.e. all zeros) Source: Property/Uuid.js Methods getDefaultValue() Gets default value. In this case, if a property is set to have a defaultValue of 'now', it will default to the current Date. Source: Property/Date.js Returns: defaultValue Type any getDefaultValue() Gets default value. Can be overridden to get dynamic default value. Source: Property/Property.js Returns: defaultValue Type any getDefaultValue() Gets default value. In this case, if a property is set to have a defaultValue of 'generate', it will default to a newly generated UUID. Source: Property/Uuid.js Returns: defaultValue Type any Module: Property Class represents a Property that stores Base64 data. This class contains helpful methods in dealing with Base64 data. Class represents a Property that stores boolean data. Class represents a Property that stores currency data. Class represents a Property that stores a calendar date. Class represents a Property that stores a calendar date and time. Class represents a Property that stores file data. Class represents a Property that stores a float value. Class represents a Property that stores an integer value. Class represents a Property that stores JSON data. JsonProperty may be a little unpredictable in what its various methods will give you. Say you set the value to: '{\"test\":true}'. The property parses this and converts it to an actual JS object internally. There will then be two possible representations of this value: - A string ('{\"test\":true}') and - An object ({ test: true }). This is what the various methods will give you: - getParsedValue: object - getDisplayValue: string - getRawValue: string - getSubmitValue (default): string - getSubmitValue when !submitAsString: object The submitValue is where things get weird. By default, this property will submit as a string. Base class representing a Property This class should not be instantiated directly. Rather, instantiate a subclass, like StringProperty Class represents a Property that stores string data. Class represents a Property that stores a time of day. Class represents a Property that stores a UUID. This class contains helpful methods in dealing with UUIDs. new (require(\"Property\"))() Source: Property/Base64.js new (require(\"Property\"))() Source: Property/Boolean.js new (require(\"Property\"))() Source: Property/Currency.js new (require(\"Property\"))() Source: Property/Date.js new (require(\"Property\"))() Source: Property/DateTime.js new (require(\"Property\"))() Source: Property/File.js new (require(\"Property\"))() Source: Property/Float.js new (require(\"Property\"))() Source: Property/Integer.js new (require(\"Property\"))() Source: Property/Json.js new (require(\"Property\"))(config) Parameters: Name Type Description config object Object with key/value pairs that define this Property Source: Property/Property.js Fires: .'change',event: 'destroy'] new (require(\"Property\"))() Source: Property/String.js new (require(\"Property\"))() Source: Property/Time.js new (require(\"Property\"))() Source: Property/Uuid.js Members decode Decodes to UTF-8 string Source: Property/Base64.js atob Decodes to bytes, which is compatible with browser's built-in atob() (Which is absent in node) Source: Property/Base64.js parse Parses value to moment object Source: Property/Date.js parse Parses value to float Source: Property/Float.js isValid Validates a JSON string Source: Property/Json.js getAsHtmlSafe Utility function - gets the JSON string in a way that is safe to display in HTML. i.e. It enables us to show a JSON string in HTML *without its contents being interpreted as HTML* Source: Property/Json.js <inner> name :string Could be anything, but OneHat's convention is to use the model name pluralized and underscored, followed by two underscores, followed by the field name singular and underscored (e.g. 'groups_users__id') This convention allows us to have multiple models' data in a single Entity, all flattened Type: string Source: Property/Property.js <inner> allowNull :boolean Is the property required to have a value? Defaults to true. Type: boolean Source: Property/Property.js <inner> submitAsString :boolean Whether to submit value as a string, rather than a primitive or complex type Type: boolean Source: Property/Property.js <inner> isSortable :boolean Whether this property type is sortable Type: boolean Source: Property/Property.js <inner> rawValue :any The raw value supplied to t