loopbackio / loopbackio/loopback-next
How to define model properties of `Object` type?
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1.1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 27
Description
I have generated a model which results in `thing.model.ts`:
```
import {Entity, model, property} from '@loopback/repository';
@model()
export class Thing extends Entity {
@property({
type: 'string',
id: true,
required: true,
})
id: string;
@property({
type: 'string',
required: true,
})
name: string;
@property({
type: 'string',
required: true,
})
description: string;
@property({
type: 'object',
required: true,
})
attributes: object;
constructor(data?: Partial) {
super(data);
}
}
```
How do I go about defining the `attributes` object? Am I only able to do this by defining another `attributes` model? My searches provide information on doing this with LB3.x but that is using a .json file and not using `@property` decorators.
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
Start with the generated thing.model.ts example and the @property decorator usage shown in the issue. Check the current LoopBack model-property documentation for supported object definitions and compare it with the older LB3 guidance. Done should be a clear documented answer or example explaining how to define attributes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100