Module: tastypie/fields/api

resource field definitions


new (require("tastypie/fields/api"))(options)

Base field providing generic functionality around value serialization / deserialization

Parameters:
Name Type Description
options Object
Properties
Name Type Argument Default Description
readonly Boolean <optional>
false

Vales will be omitted during the hydration cycle

nullable Boolean <optional>
false

true of the field should allow for a null vlaue

attribute String | function <optional>
null

A name path or function to be used to extract values during dehydration

name String <optional>
null

The name of the field. This is automatically set when added to a resource

help String <optional>
A general no-op field

Help text to include in the schema defintion for this field

default Mixed <optional>
null

A default value for the field to fill in if none is provided

exclude Boolean <optional>
false

If true the field values will be excluded from dehydration & response payloads

Mixes In:
Source:
Example
var x = new tastypie/fields.ApiField();

Requires

Methods


<protected> augment(resource, name)

Injects dynamic properties onto field instance for later use

Parameters:
Name Type Description
resource Resource

the resource instance this field is attached to

name String

The property name this field is associated to

Source:

convert(val)

Converts data value into the serialization specific type.

Parameters:
Name Type Description
val Mixed

value to convert

Source:
Returns:

value The converted field value

Type
Mixed

dehydrate(object, attribute)

Converts a javascript object / value into something sutable for seriaation. ex. Date formatting

Parameters:
Name Type Description
object Object

Object to dehydrate before serialization

attribute Sting | function

a name path or function to use to retrieve a value from the object

Source:
Returns:

value object value converted to its internal type

Type
Mixed

format()

returns a sample of the format expected and returned by a field

Source:
Returns:

The format expected for a particular field type

Type
String | undefined

hydrate(bundle)

Converts a serialized value in to a javascript object value

Parameters:
Name Type Description
bundle Bundle

a bundle representing the current request

Source: