Open maasencioh opened 3 years ago
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.
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
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;
}
https://github.com/zakodium/adonis-mongodb/blob/638a5ec3054c92aec75fc144eb7ca331ee567b50/adonis-typings/odm.ts#L365