Skip to content

Commit ea1b219

Browse files
kriszypcb1kenobi
andauthored
Update docs/technical-details/reference/resource-migration.md
Co-authored-by: Chris Barber <[email protected]>
1 parent 397ccb5 commit ea1b219

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/technical-details/reference/resource-migration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The Resource API was inspired by two major design ideas: the REST architectural design and the [Active Record pattern](https://en.wikipedia.org/wiki/Active_record_pattern) (made popular by Ruby on Rails and heavily used as a pattern in many ORMs). The basic design goal of the Resource API is to integrate these concepts into a single construct that can directly map RESTful methods (specifically the "uniform interface" of HTTP) to an active record data model. However, while the active record pattern has been for _consumption_ of data, implementing methods for endpoint definitions and caching sources as a data _provider_ can be confusing and cumbersome to implement. The updated non-instance binding Resource API is designed to make it easier and more consistent to implement a data provider and interact with records across a table, while maintaining more explicit control over what data is loaded and when.
44

5-
The updated Resource API is enabled on a per-class basis, by setting static `loadAsInstance` property to `false`. When this property is set to `false`, this means that the Resource instances will not be bound to a specific record, and instead instances represent the whole table, capturing the context and current transactional state. Any records in the table can be loaded or modified from `this` instance. There are a number of implications and different behaviors from a Resource class with `static loadAsInstance = false`:
5+
The updated Resource API is enabled on a per-class basis by setting static `loadAsInstance` property to `false`. When this property is set to `false`, this means that the Resource instances will not be bound to a specific record. Instead instances represent the whole table, capturing the context and current transactional state. Any records in the table can be loaded or modified from `this` instance. There are a number of implications and different behaviors from a Resource class with `static loadAsInstance = false`:
66
* The `get` method (both static and instance) will directly return the record, a frozen enumerable object with direct properties, instead of a Resource instance.
77
* When instance methods are called, there will not be any record preloaded beforehand and the resource instance will not have properties mapped to a record.
88
* All instance methods accept a `target`, an instance of `RequestTarget`, as the first argument, which identifies the target record or query.

0 commit comments

Comments
 (0)