Open ghost opened 6 years ago
Regarding the @ObjectID
decorator, there is actually a bug in their code.
Here is where the bug is: https://github.com/SierraSoftworks/Iridium/blob/master/lib/Decorators.ts#L144
They simply need to change the order of the calls to the Property
and Transform
decorators and they will be good to go.
Further, they might consider changing the decorator to something like below to allow the user to make the field required or not.
export function ObjectId(required = true)
{
return function(target, name)
{
Transform(DefaultTransforms.ObjectID.fromDB, DefaultTransforms.ObjectID.toDB)(target, name);
Property(ObjectId, required)(target, name);
};
}
It seems there is actually a larger issue with their @Property
decorator not properly requiring an ObjectId
but always allowing that to be optional...
Working with
iridium@8.0.0-alpha.13
onnode@9.4.0
andnpm@6.0.1
.Four things here: 1) The built-in
Date
validator won't accept a valid date string. Is that intentional? 2)Model.save
doesn't execute transforms. Is that also intentional? 3) I can't make anObjectID
field other than_id
required. 4)ObjectID
s are not converted to strings on retrievalConsider the following test: