Service Interface
A service can implement any combination of the following methods:Standard Methods
find()
Retrieve a list of resources. Can return paginated or unpaginated results.Params
Service call parameters
Query
Query parameters for filtering, sorting, and pagination
PaginationParams
Pagination configuration. Set to
false to disable pagination.Result[] | Paginated<Result>
Array of results, or a paginated result object with
total, limit, skip, and data propertiesget()
Retrieve a single resource by its unique identifier.Id
required
The unique identifier of the resource (number or string)
Params
Service call parameters
Result
The resource object
create()
Create one or more new resources.Data | Data[]
required
The data for the new resource(s). Can be a single object or an array of objects.
Params
Service call parameters
Result | Result[]
The created resource(s)
update()
Replace a resource or multiple resources. Theupdate method completely replaces the resource(s).
Id | null
required
The unique identifier of the resource. Use
null to update multiple resources.Data
required
The complete new data for the resource(s)
Params
Service call parameters
Result | Result[]
The updated resource(s)
patch()
Merge updates into a resource or multiple resources. Unlikeupdate, patch only modifies the provided fields.
Id | null
required
The unique identifier of the resource. Use
null to patch multiple resources.PatchData
required
Partial data to merge into the resource(s)
Params
Service call parameters
Result | Result[]
The patched resource(s)
remove()
Remove a resource or multiple resources.Id | null
required
The unique identifier of the resource. Use
null to remove multiple resources.Params
Service call parameters
Result | Result[]
The removed resource(s)
Lifecycle Methods
setup()
Called when the application is started. Use this to initialize connections, load data, etc.Application
required
The Feathers application instance
string
required
The path where this service is registered
teardown()
Called when the application is shut down. Use this to close connections, clean up resources, etc.Application
required
The Feathers application instance
string
required
The path where this service is registered
Service Parameters
Params
Theparams object contains metadata about the service call:
Query
Query parameters for filtering and pagination
string
The transport that made the service call (e.g.,
'rest', 'socketio', undefined for internal calls)object
Route parameters from the URL path
object
HTTP headers from the request
Service Options
When registering a service, you can pass options:string[]
Custom events that this service emits to clients (merged with default events)
string[]
Service methods that should be available externally to clients
string[]
Full list of events this service emits (replaces default events)
object
Initial data to always add as route params to this service
Custom Service Methods
Services can have custom methods in addition to the standard CRUD methods:Protected Method Names
The following method names are reserved and cannot be used as custom methods:- All methods from
Object.prototypeandEventEmitter.prototype all,around,before,after,errorhooks,setup,teardown,publish