Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_id default type should be ObjectId instead unknown #118

Open
maasencioh opened this issue Oct 11, 2021 · 3 comments
Open

_id default type should be ObjectId instead unknown #118

maasencioh opened this issue Oct 11, 2021 · 3 comments

Comments

@maasencioh
Copy link

export const BaseModel: MongodbModel<unknown>;

@targos
Copy link
Member

targos commented Oct 11, 2021

This is not the default type, as there is no way to have a "default" for exported values. Try to put ObjectId here, it will break the package.

@maasencioh
Copy link
Author

As far as I understand when you do something like this

export default class Test extends BaseModel {
  @field()
  public foo: string;
}

in the database will use _id as ObjectId, then I think that it should made sense that change

@targos
Copy link
Member

targos commented Oct 11, 2021

Feel free to try it, but this change didn't work when I implemented the typings. I agree that unknown is not the best thing here, but I haven't found an alternative yet that allows to change the type to something else. (for example number or string).
In our models, we always add the type for _id:

class SomeModel extends BaseModel {
  @field()
  override _id: ObjectId;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants