breeze-client / DataType
Class: DataType
Defined in: src/metadata/data-type.ts:27
DataType is an 'Enum' containing all of the supported data types.
Extends
Constructors
Constructor
new DataType(
propertiesObj?):DataType
Defined in: src/core/enum.ts:72
Creates a symbol, copying each property of propertiesObj onto it. Used to declare the symbols of an enum, as static members of its class; its name is set when the class calls BreezeEnum.resolveSymbols.
Parameters
propertiesObj?
Object
Returns
DataType
Inherited from
Properties
_$typeName
_$typeName:
string
Defined in: src/core/enum.ts:60
Type of the enum; set in prototype of each enum
Inherited from
defaultValue?
optionaldefaultValue?:any
Defined in: src/metadata/data-type.ts:29
The default value of this DataType. Read Only
isInteger?
optionalisInteger?:boolean
Defined in: src/metadata/data-type.ts:33
Whether this is an 'integer' DataType. Read Only
isNumeric?
optionalisNumeric?:boolean
Defined in: src/metadata/data-type.ts:31
Whether this is a 'numeric' DataType. Read Only
name
name:
string
Defined in: src/core/enum.ts:58
The name of this symbol
Inherited from
Binary
staticBinary:DataType
Defined in: src/metadata/data-type.ts:208
Binary data (.NET byte[]), such as a SQL rowversion, held as the base64 string the server sends. Default null.
Boolean
staticBoolean:DataType
Defined in: src/metadata/data-type.ts:193
A true or false value (.NET Boolean). Default false.
Byte
staticByte:DataType
Defined in: src/metadata/data-type.ts:113
An unsigned 8-bit integer, 0 to 255 (.NET Byte), held as a number. Default 0.
DateOnly
staticDateOnly:DataType
Defined in: src/metadata/data-type.ts:148
A calendar date with no time (.NET DateOnly), held as a Date at local midnight. Read from the first ten characters (YYYY-MM-DD) of the server's value, sent back as YYYY-MM-DD from the local date, and compared by date alone. Default 1 January 1900.
DateTime
staticDateTime:DataType
Defined in: src/metadata/data-type.ts:159
A date and time (.NET DateTime), held as a Date. Read from the server with DataType.parseDateFromServer and sent as ISO 8601 in UTC. Also the type Breeze infers for an unmapped property that holds a Date. Default 1 January 1900, local midnight.
DateTimeOffset
staticDateTimeOffset:DataType
Defined in: src/metadata/data-type.ts:170
A date and time with an offset (.NET DateTimeOffset), held as a Date, which has no offset: it is read with DataType.parseDateFromServer and sent back in UTC, so the original offset is lost. Default 1 January 1900, local midnight.
Decimal
staticDecimal:DataType
Defined in: src/metadata/data-type.ts:121
A decimal number (.NET Decimal), held as a JavaScript number - a double - so digits beyond its precision are lost. Default 0.
Double
staticDouble:DataType
Defined in: src/metadata/data-type.ts:130
A 64-bit floating-point number (.NET Double). Also the type Breeze infers for an unmapped property that holds a number. Default 0.
Guid
staticGuid:DataType
Defined in: src/metadata/data-type.ts:199
A GUID (.NET Guid), held as a lower-case string. Default "00000000-0000-0000-0000-000000000000".
Int16
staticInt16:DataType
Defined in: src/metadata/data-type.ts:104
A 16-bit integer (.NET Int16; also SByte), held as a number. Default 0.
Int32
staticInt32:DataType
Defined in: src/metadata/data-type.ts:95
A 32-bit integer (.NET Int32; also UInt16), held as a number. Default 0.
Int64
staticInt64:DataType
Defined in: src/metadata/data-type.ts:86
A 64-bit integer (.NET Int64; also UInt32 and UInt64), held as a JavaScript number, so values beyond ±2^53 lose precision. Default 0.
Single
staticSingle:DataType
Defined in: src/metadata/data-type.ts:139
A 32-bit floating-point number (.NET Single), held as a number. Default 0.
String
staticString:DataType
Defined in: src/metadata/data-type.ts:79
A string (.NET String; also Char). Default "".
Time
staticTime:DataType
Defined in: src/metadata/data-type.ts:181
A duration (.NET TimeSpan), held as the ISO 8601 duration string the server sends, such as PT4H30M. Compared as a number of seconds in local queries. Default PT0S.
TimeOnly
staticTimeOnly:DataType
Defined in: src/metadata/data-type.ts:188
A time of day (.NET TimeOnly), held as the string the server sends: "14:30:00" or "01:23:45.678".
Undefined
staticUndefined:DataType
Defined in: src/metadata/data-type.ts:214
An unknown type: a server type name the client does not recognize (the original is kept in the property's rawTypeName), or an unmapped property whose type cannot be inferred. Values are not converted or validated. Default undefined.
Methods
getConcurrencyValue()?
optionalgetConcurrencyValue(previousValue?):any
Defined in: src/metadata/data-type.ts:63
Optional function to get the next value when the datatype is used as a concurrency property.
Parameters
previousValue?
any
Returns
any
the next concurrency value, which may be a function of the previousValue.
getNext()?
optionalgetNext():any
Defined in: src/metadata/data-type.ts:57
Optional function to get the next value for key generation, if this datatype is used as a key. Uses an internal table of previous values.
Returns
any
value appropriate for this DataType
normalize()?
optionalnormalize(value):any
Defined in: src/metadata/data-type.ts:42
Optional function to normalize a data value for comparison, if its value cannot be used directly. Note that this will be called each time a property is changed, so make it fast.
Parameters
value
any
Returns
any
value appropriate for this DataType
parse()?
optionalparse(source,sourceTypeName):any
Defined in: src/metadata/data-type.ts:52
Optional function to convert a value from string to this DataType. Note that this will be called each time a property is changed, so make it fast.
Parameters
source
any
sourceTypeName
string
Returns
any
value appropriate for this DataType
parseRawValue()?
optionalparseRawValue(value):any
Defined in: src/metadata/data-type.ts:47
Optional function to convert a raw (server) value from string to this DataType.
Parameters
value
any
Returns
any
value appropriate for this DataType
toJSON()
toJSON():
object
Defined in: src/core/enum.ts:180
Return enum name and symbol name
Returns
_$typeName
_$typeName:
any
The name of the enum, such as "EntityState".
name
name:
string
The name of the symbol, such as "Added".
Inherited from
toString()
toString():
string
Defined in: src/core/enum.ts:175
Returns the string name of this Enum
Returns
string
Inherited from
validatorCtor()?
optionalvalidatorCtor(context?):Validator
Defined in: src/metadata/data-type.ts:36
The constructor function to create a Validator to be used in validating instances of this DataType.
Parameters
context?
any
Returns
contains()
staticcontains(sym):boolean
Defined in: src/core/enum.ts:154
Returns whether an Enum contains a specified symbol.
let symbol = DayOfWeek.Friday;
if (DayOfWeek.contains(symbol)) {
// do something
}Parameters
sym
Object or symbol to test.
Returns
boolean
Whether this Enum contains the specified symbol.
Inherited from
fromName()
staticfromName(name):DataType|undefined
Defined in: src/metadata/data-type.ts:245
Returns the DataType with the specified name, or undefined if there is none. Also accepts the names the .NET servers use for some types, such as 'TimeSpan' for DataType.Time.
Parameters
name
string
Returns
DataType | undefined
Overrides
fromValue()
staticfromValue(val):DataType
Defined in: src/metadata/data-type.ts:251
Returns the DataType for a specified input.
Parameters
val
any
Returns
DataType
getComparableFn()
staticgetComparableFn(dataType?): (value) =>any
Defined in: src/metadata/data-type.ts:225
Returns the function Breeze uses to turn values of a data type into something ===, < and > compare correctly, in local queries and when ordering: the data type's normalize if it has one, a conversion to seconds for DataType.Time, and otherwise the value itself. Applications do not normally need it.
Parameters
dataType?
DataType
The data type of the values to compare.
Returns
(
value):any
Optional function to normalize a data value for comparison, if its value cannot be used directly. Note that this will be called each time a property is changed, so make it fast.
Parameters
value
any
Returns
any
value appropriate for this DataType
getNames()
staticgetNames():string[]
Defined in: src/core/enum.ts:100
Returns the names of all of the symbols contained within this Enum.
let symbols = DayOfWeek.getNames();Returns
string[]
All of the names of the symbols contained within this Enum.
Inherited from
getSymbols()
staticgetSymbols<T>(this):InstanceType<T>[]
Defined in: src/core/enum.ts:86
Returns all of the symbols contained within this Enum.
let symbols = DayOfWeek.getSymbols();Type Parameters
T
T extends typeof BreezeEnum
Parameters
this
T
Returns
InstanceType<T>[]
All of the symbols contained within this Enum.
Inherited from
parseDateAsLocal()
staticparseDateAsLocal(source):any
Defined in: src/metadata/data-type.ts:299
Parse as UTC then shift to local time
Parameters
source
string
Returns
any
parseDateAsUTC()
staticparseDateAsUTC(source):any
Defined in: src/metadata/data-type.ts:289
Converts a date-time string from the server to a Date. This is the default DataType.parseDateFromServer.
- A string with
Zor an offset (2024-03-15T10:30:00Z,...10:30:00+02:00) is read as given. - A string with no offset that ends in fractional seconds, of any length (
2024-03-15T10:30:00.5,...00.000,...00.1234567), is read as UTC: Breeze appendsZ. - Any other string with no offset, such as
2024-03-15T10:30:00, goes toDate.parseunchanged, which reads it as local time.
Parameters
source
any
The value from the server.
Returns
any
parseDateFromServer()
staticparseDateFromServer(value):any
Defined in: src/metadata/data-type.ts:71
The function Breeze converts DateTime and DateTimeOffset values from the server with, when it materializes query and save results. Defaults to DataType.parseDateAsUTC. Replace it at startup, before the first query, to change how a date-time string with no offset is read - for example with DataType.parseDateAsLocal. It does not affect saves, which always send UTC.
Parameters
value
any
Returns
any
parseRawValue()
staticparseRawValue(val,dataType?):any
Defined in: src/metadata/data-type.ts:315
Returns a raw value converted to the specified DataType
Parameters
val
any
dataType?
DataType
Returns
any
parseTimeFromServer()
staticparseTimeFromServer(source):any
Defined in: src/metadata/data-type.ts:275
Converts a DataType.Time value from the server. By default it returns the value unchanged: a Time is held as the ISO 8601 duration string the server sends, such as PT4H30M. Replace it at startup, before the first query, to hold durations some other way - as a number of seconds, say, with core.durationToSeconds.
Parameters
source
any
Returns
any
resolveSymbols()
staticresolveSymbols():object[]
Defined in: src/core/enum.ts:124
Seals this enum so that no more symbols may be added to it. This should only be called after all symbols have already been added to the Enum. This method also sets the 'name' property on each of the symbols.
DayOfWeek.resolveSymbols();Returns
Inherited from
toDateOnlyString()
statictoDateOnlyString(val):any
Defined in: src/metadata/data-type.ts:308
if val is a Date, return a date-only string e.g. '2023-12-31'
Parameters
val
any
Returns
any