This component handles database queries, utilize the deserializer to figure out models and column names and returns the data to the RESTfulAPI.
||key => value pair specifying which deserializer to use||'deSerializer' => '%$Colymba\RESTfulAPI\Serializers\DefaultDeSerializer'|
||Separator used in HTTP params between the column name and the search filter modifier (e.g. ?name__StartsWith=Henry will find models with the column name that starts with 'Henry'. ORM equivalent ->filter(array('name::StartsWith' => 'Henry')) )||'__'|
||Uppercased query params that would not parsed as column names (uppercased)||'URL', 'FLUSH', 'FLUSHTOKEN'|
||specify the maximum number of records to return by default (avoid the api returning millions...)||100|
||Array of mappings of URL segments to class names|||
Search filter modifiers
This also accept search filter modifiers in HTTP variables (see Search Filter Modifiers) like:
As well as special modifiers
limit with these possible formatting:
Search filter modifiers are recognised/extracted thanks to the
searchFilterModifiersSeparator config. The above examples assume the default
searchFilterModifiersSeparator is in use.
models configuration option it is possible to map the URL segment that follows
/api/ to a particular model class name. This can be used to override the default behaviour which will use a lower cased version of the model name, for example
Member will become
It is a requirement to use this mapping when exposing namespaced classes because they do not map to a single URL segment.
Colymba\RESTfulAPI\QueryHandlers\DefaultQueryHandler: models: member: SilverStripe\Security\Member
Model hooks are available on both serialization and deserialization. These can be used to control what of the model data gets serialized (eg. sent to the client) or what will gets written into the model after deserialization.
Here are the available callbacks (can be directly implemented on the
DataObject or in a
||Called before the model is being serialized. You can set fields to
||Called after the model has been serialized. This is the complete dataset that will be converted to JSON and sent to the client. You can use
||Called before the raw JSON is being parsed. You get access to the raw JSON data sent by the client.|
||Called after JSON has been deserialized into an array map. You can modify this array to prevent incoming values to be applied to your model (sanitize incoming data).|