Anatomy of a call
sdk.[driver].[resource].[method](payload?, onEvent?, extra?)| Parameter | Type | Role |
|---|---|---|
payload |
object |
Filter, query, record to create. Its shape is defined by the driver. |
onEvent |
SdkEventHandler |
Event callback for this call, run together with the global notify of createSdk. |
extra |
unknown |
Opaque to the core. Most drivers ignore it; nhost reads { fragment } from it. |
Rules of the proxy:
driveris a key ofdrivers.resourceis any name: it is passed to the driver as the resource name, and bound to theresourcesentry with the same key when there is one.methodmust be a method of the driver. An unknown method throwsDriver "x" has no method "y" for resource "z".- Methods of
Object.prototype(toString,constructor…) are not callable through a resource. - A resource key must not match any member of the driver (
name,bindResource, a method, a private field such asresourcesorbaseUrl, or anObject.prototypename).createSdkthrowsResource "x" collides with a member of driver "y" (z): rename the resource keywhen it binds the resources.
Events: request, success, error, data, connected, disconnected. See Events.