infinum / datx

DatX is an opinionated JS/TS data store. It features support for simple property definition, references to other models and first-class TypeScript support.
https://datx.dev
MIT License
139 stars 7 forks source link

enableAutoId has no effect #1214

Open angabriel opened 1 week ago

angabriel commented 1 week ago

Used libraries

core, jsonapi, angular-jsonapi

Library version(s)

@datx/core 3.0.0, @datx/jsonapi 3.0.0, @datx/jsonapi-angular 3.0.0

Sample API response (if relevant)

No response

Environments with the issue

Everwhere

Environments without the issue

No response

Current behavior


class MyJsonModel extends jsonapiAngular(Model) {
  @Field({ isIdentifier: true, enableAutoId: false })
  public id!: string;
}

When I do new MyJsonModel() I get ids like "-1", "-2" and so on. So Its hard to differntiate between models that need to be created (POST) oder updated (PATCH).

Expected behavior

The id should be undefined or null when doing

@Field({ isIdentifier: true, enableAutoId: false })
  public id?: string;`

Reproduction steps

1.
2.
3.
...