File tree Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
8
8
## [ Unreleased]
9
9
10
+ ### Added
11
+
12
+ - Allow syncing ` null ` document data.
13
+
10
14
## [ 0.2.0-beta.1] - 2024-05-14
11
15
12
16
### ⚠️ Breaking Changes
Original file line number Diff line number Diff line change @@ -61,9 +61,15 @@ export class Store<Schemas extends SchemaCollection = {}> {
61
61
) : ModelForType < Type , Schemas > | ModelForType < Type , Schemas > [ ] | null {
62
62
document . included ?. map ( ( resource ) => this . syncResource ( resource ) ) ;
63
63
64
- return Array . isArray ( document . data )
65
- ? document . data . map ( ( resource ) => this . syncResource ( resource ) )
66
- : this . syncResource ( document . data ) ;
64
+ if ( Array . isArray ( document . data ) ) {
65
+ return document . data . map ( ( resource ) => this . syncResource ( resource ) ) ;
66
+ }
67
+
68
+ if ( document . data ) {
69
+ return this . syncResource ( document . data ) ;
70
+ }
71
+
72
+ return null ;
67
73
}
68
74
69
75
public syncResource < Type extends ( keyof Schemas & string ) | ( string & { } ) > (
Original file line number Diff line number Diff line change 1
1
import { Model } from './model.ts' ;
2
2
3
3
export interface JsonApiDocument < Type extends string = string > {
4
- data : JsonApiResource < Type > | JsonApiResource < Type > [ ] ;
4
+ data : JsonApiResource < Type > | JsonApiResource < Type > [ ] | null ;
5
5
included ?: JsonApiResource [ ] ;
6
6
meta ?: Record < string , any > ;
7
7
links ?: Record < string , any > ;
You can’t perform that action at this time.
0 commit comments