Creates and returns a new resource instance without writing to or modifying ctx.resource. It is suitable for scenarios requiring multiple independent resources or temporary usage.
| Scenario | Description |
|---|---|
| Multiple resources | Load multiple data sources simultaneously (e.g., user list + order list), each using an independent resource. |
| Temporary queries | One-time queries that are discarded after use, without needing to bind to ctx.resource. |
| Auxiliary data | Use ctx.resource for primary data and makeResource to create instances for additional data. |
If you only need a single resource and want to bind it to ctx.resource, using ctx.initResource() is more appropriate.
| Parameter | Type | Description |
|---|---|---|
resourceType | string | Resource type: 'APIResource', 'SingleRecordResource', 'MultiRecordResource', 'SQLResource' |
Returns: The newly created resource instance.
| Method | Behavior |
|---|---|
ctx.makeResource(type) | Only creates and returns a new instance, not writing to ctx.resource. Can be called multiple times to obtain multiple independent resources. |
ctx.initResource(type) | Creates and binds if ctx.resource does not exist; returns it directly if it already exists. Ensures ctx.resource is available. |
setResourceName(name) to specify the collection, and then load data via refresh().ctx.resource