loopbackio / loopbackio/loopback-next

Nested model property of type Date returned as string

Open
#9,337 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.