loopbackio / loopbackio/loopback-next
Nested model property of type Date returned as string
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1.1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 27
Description
### Describe the bug
When retrieving type Date property on a nested model (property decorator) the property is returned as a string instead of Date.
```ts
@model()
class Nested extends Entity {
@property()
date: Date;
}
@model()
class Other extends Entity {
@property()
nested: Nested;
}
```
`typeof other.nested.date` should be Date but is string
Ran locally with memory db.
I also tried using @embedsOne, but couldn't get the decorator to work, the nested property wasn't saved on the other model instance.
### Logs
_No response_
### Additional information
_No response_
### Reproduction
/
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the TypeScript nested-model example with the memory database, starting from the property decorators and checking how the nested Date value is saved and retrieved. Done means other.nested.date is a Date rather than a string; the attempted @embedsOne behavior is also clarified if it remains in scope.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100