Skip to content

Commit

Permalink
Fix falsy attribute values not being returned
Browse files Browse the repository at this point in the history
  • Loading branch information
tobyzerner committed Oct 2, 2024
1 parent 536b050 commit 3ad3252
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fix falsy attribute values not being returned

## [0.2.0-beta.4] - 2024-10-01

### Changed
Expand Down
4 changes: 2 additions & 2 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ export class Store<Schemas extends SchemaCollection = {}> {
return new Proxy(new ModelClass(data), {
get: (target, prop, receiver) => {
if (typeof prop === 'string') {
if (target.attributes?.[prop]) {
if (target.attributes?.[prop] !== undefined) {
return target.attributes[prop];
}
const data = target.relationships?.[prop]?.data;
if (data) {
if (data !== undefined) {
return Array.isArray(data)
? this.find(data)
: this.find(data);
Expand Down

0 comments on commit 3ad3252

Please sign in to comment.