Commit 6917338
authored
feat(model): add method wrapper to define the api response wrapper / overrides (#281)
- Added wrap, _unwrap, wrappedBy, and nowrap methods to Model.js to mimic Laravel's resource data wrapping. This makes for `$first`, `$find`, `$get`, and `$all` obsolete but I kept them for backward compatibility. The the overloadable `wrap()` allows you to automatically unwrap using the standard `first`, `find`, `get`, `all` methods but also change what the wrapper key is in case you don't want to use the standard 'data' property
- Added unit tests for the new wrap() method
- Added new `wrap()` type
- Added new `wrappedBy(wrap)` and `nowrap()` builder methods to change / disable wrapping
- Updated documentation for new `wrap()` type
- Updated documentation for new `wrappedBy()` and `nowrap()` methods1 parent 2bb3f4b commit 6917338
File tree
7 files changed
+316
-47
lines changed- docs/content/en
- api
- src
- tests
7 files changed
+316
-47
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| 36 | + | |
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
| |||
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
| |||
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
| 73 | + | |
69 | 74 | | |
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
| 78 | + | |
73 | 79 | | |
74 | 80 | | |
75 | 81 | | |
76 | 82 | | |
| 83 | + | |
77 | 84 | | |
78 | 85 | | |
79 | 86 | | |
80 | 87 | | |
| 88 | + | |
81 | 89 | | |
82 | 90 | | |
83 | 91 | | |
84 | 92 | | |
| 93 | + | |
85 | 94 | | |
86 | 95 | | |
87 | 96 | | |
88 | 97 | | |
| 98 | + | |
89 | 99 | | |
90 | 100 | | |
91 | 101 | | |
92 | 102 | | |
| 103 | + | |
93 | 104 | | |
94 | 105 | | |
95 | 106 | | |
96 | 107 | | |
| 108 | + | |
97 | 109 | | |
98 | 110 | | |
99 | 111 | | |
| |||
112 | 124 | | |
113 | 125 | | |
114 | 126 | | |
| 127 | + | |
115 | 128 | | |
116 | 129 | | |
117 | 130 | | |
| |||
133 | 146 | | |
134 | 147 | | |
135 | 148 | | |
| 149 | + | |
136 | 150 | | |
137 | 151 | | |
138 | 152 | | |
| |||
146 | 160 | | |
147 | 161 | | |
148 | 162 | | |
| 163 | + | |
149 | 164 | | |
150 | 165 | | |
151 | 166 | | |
| |||
159 | 174 | | |
160 | 175 | | |
161 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
162 | 192 | | |
| 193 | + | |
163 | 194 | | |
164 | 195 | | |
165 | | - | |
| 196 | + | |
166 | 197 | | |
167 | 198 | | |
168 | 199 | | |
| |||
179 | 210 | | |
180 | 211 | | |
181 | 212 | | |
| 213 | + | |
182 | 214 | | |
183 | 215 | | |
184 | 216 | | |
| |||
0 commit comments