3

It is the first time that I use this version (4) for development and I have a problem with loopback and mongodb indexing.

Of the two ids that are inside the db loopback it does not collect any.

It's a problem of the API or DB?


Model [Loopback]

import { Entity, model, property } from '@loopback/repository';

@model()
export class Ad extends Entity {
  @property({
    type: 'number',
    id: true,
    required: true,
  })
  id: number;
 <...>
  constructor(data?: Partial<Ad>) {
    super(data);
  }
}

Data on Mongo:

{
    "_id": {
        "$oid": "5c0e9c7730146d2448746834"
    },
    "id": 110722,
    "creation_date": 1492075600000,
    "update_date": 1492075921000,
    ...
}

Response on loopback GET /ads

[{
    "id": null,
    "creation_date": 1492075600000,
    "update_date": 1492075921000,
    ...
  },...]
4

1 回答 1

1

来自 LoopBack 团队的您好 :)

我在您发布的代码片段中没有看到任何明显的问题。当您将 id 的类型从 更改number为时会发生什么string?它会解决问题吗?

很可能,您在 LoopBack 4 中发现了一个错误。请通过 GitHub 报告:https ://github.com/strongloop/loopback-next/issues

于 2018-12-11T13:01:17.683 回答